今天创建新的个人博客遇到一个小小问题,
修改npm的全局安装路径之后,执行npm i webpack webpack -g测试和npm install 包时发生错误,但是在管理员身份下运行cmd,均能执行成功
具体错误如下:
npm ERR! code EPERM npm ERR! syscall mkdir npm ERR! path D:\soft\Nodejs\node_cache\_cacache npm ERR! errno -4048 npm ERR! Error: EPERM: operation not permitted, mkdir 'D:\soft\Nodejs\node_cache\_cacache' npm ERR! [Error: EPERM: operation not permitted, mkdir 'D:\soft\Nodejs\node_cache\_cacache'] { npm ERR! errno: -4048, npm ERR! code: 'EPERM', npm ERR! syscall: 'mkdir', npm ERR! path: 'D:\\soft\\Nodejs\\node_cache\\_cacache' npm ERR! } npm ERR! npm ERR! The operation was rejected by your operating system. npm ERR! It's possible that the file was already in use (by a text editor or antivirus), npm ERR! or that you lack permissions to access it. npm ERR! npm ERR! If you believe this might be a permissions issue, please double-check the npm ERR! permissions of the file and its containing directories, or try running npm ERR! the command again as root/Administrator. npm ERR! Log files were not written due to an error writing to the directory: D:\soft\Nodejs\node_cache\_logs npm ERR! You can rerun the command with `--loglevel=verbose` to see the logs in your terminal`
复制
根本原因是无管理员权限,也就无法在node_global和node_cache两个文件夹下进行操作
解决方法如下:
直接修改两个文件夹的权限即可,右键需修改的文件夹如图,选择安全,编辑权限将所有√都选上。
之后运行
npm install webpack -g
复制
测试成功,问题解决。