原因:我们在安装node.js的时候将 node_cache、node_global 文件夹查询配置到了其他盘下面,导致无权限访问
报错问题:
npm ERR! code EPERM
npm ERR! syscall open
npm ERR! path D:\nodeJs\node_cache\_cacache\tmp\a3f11967
npm ERR! errno -4048
npm ERR! Error: EPERM: operation not permitted, open 'D:\nodeJs\node_cache\_cacache\tmp\a3f11967'
npm ERR! [OperationalError: EPERM: operation not permitted, open 'D:\nodeJs\node_cache\_cacache\tmp\a3f11967'] {
npm ERR! cause: [Error: EPERM: operation not permitted, open 'D:\nodeJs\node_cache\_cacache\tmp\a3f11967'] {
npm ERR! errno: -4048,
npm ERR! code: 'EPERM',
npm ERR! syscall: 'open',
npm ERR! path: 'D:\\nodeJs\\node_cache\\_cacache\\tmp\\a3f11967'
npm ERR! },
npm ERR! isOperational: true,
npm ERR! errno: -4048,
npm ERR! code: 'EPERM',
npm ERR! syscall: 'open',
npm ERR! path: 'D:\\nodeJs\\node_cache\\_cacache\\tmp\\a3f11967'
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.
解决:
> 提供两种方式解决问题
1. 将cmd窗口使用管理员方式打开,执行npm的命令即可
2. 我们在本地将这个文件夹赋予权限即可