使用npm install 或 进行相关操作,突然如下报错:
npm ERR! code EPERM
npm ERR! syscall open
npm ERR! path D:\nodejs\node_cache\_cacache\tmp\c440ef85
npm ERR! errno -4048
npm ERR! Error: EPERM: operation not permitted, open 'D:\nodejs\node_cache\_cacache\tmp\c440ef85'
npm ERR! [Error: EPERM: operation not permitted, open 'D:\nodejs\node_cache\_cacache\tmp\c440ef85'] {
npm ERR! errno: -4048,
npm ERR! code: 'EPERM',
npm ERR! syscall: 'open',
npm ERR! path: 'D:\\nodejs\\node_cache\\_cacache\\tmp\\c440ef85'
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:\nodejs\node_cache\_logs
npm ERR! You can rerun the command with `--loglevel=verbose` to see the logs in your terminal
在第 13 行就可以看到,报错是
The operation was rejected by your operating system. It's possible that the file was already in use (by a text editor or antivirus), or that you lack permissions to access it.
通常的第一反应是权限不够,所以直接使用管理员权限打开终端,接着执行相同的命令,结果依然无法解决问题,所以找到了如下的方式解决
解决方式
1、删除.npmrc文件
该文件在C:\Users\{当前登录的用户名}\ 文件夹下,如果没有找到,大概率是没有打开 隐藏的项目,在下方图片中选择显示,即可找到