问题描述
在终端中npm i nrm -g 时报错:
npm ERR! code EPERM
npm ERR! syscall open
npm ERR! path D:\Program Files\nodejs\node_cache\_cacache\index-v5\75\02\3ca596adb2cfb46ea27c270d0cf5548fa56756ba4b4f5992adde345ca289
npm ERR! errno -4048
npm ERR! Error: EPERM: operation not permitted, open 'D:\Program Files\nodejs\node_cache\_cacache\index-v5\75\xxx'
npm ERR! [Error: EPERM: operation not permitted, open 'D:\Program Files\nodejs\node_cache\_cacache\index-v5\75\02\3ca596adb2cfb46ea27c270d0cf5548fa56756ba4b4f5992adde345ca289'] {
npm ERR! errno: -4048,
npm ERR! code: 'EPERM',
npm ERR! syscall: 'open',
npm ERR! path: 'D:\\Program Files\\nodejs\\node_cache\\_cacache\\index-v5\\75\\02\\3ca596adb2cfb46ea27c270d0cf5548fa56756ba4b4f5992adde345ca289',
npm ERR! requiredBy: '.'
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! A complete log of this run can be found in:
安装网上的解决方法删除了C:\user\xxx\.npmrc
文件后,确实可以暂时解决该问题,但是 npm 的 config 也被重置,重新设置 config 后又会出现以上报错。
原因分析:
operation not permitted 提示权限不够
解决方案:
提示:以管理员身份打开终端 npm i nrm -g 即可