windows系统下使用node.js在使用npm安装tyarn时报错的解决方法,
下列方法适用大部分npm下载权限不足问题
npm ERR! code EPERM
npm ERR! syscall open
npm ERR! path C:\Program Files\nodejs\npm_cache\_cacache\tmp\2f17465b
npm ERR! errno -4048
npm ERR! Error: EPERM: operation not permitted, open 'C:\Program Files\nodejs\npm_cache\_cacache\tmp\2f
17465b'
npm ERR! [OperationalError: EPERM: operation not permitted, open 'C:\Program Files\nodejs\npm_cache\_c
acache\tmp\2f17465b'] {
npm ERR! cause: [Error: EPERM: operation not permitted, open 'C:\Program Files\nodejs\npm_cache\_caca
che\tmp\2f17465b'] {
npm ERR! errno: -4048,
npm ERR! code: 'EPERM',
npm ERR! syscall: 'open',
npm ERR! path: 'C:\\Program Files\\nodejs\\npm_cache\\_cacache\\tmp\\2f17465b'
npm ERR! },
npm ERR! isOperational: true,
npm ERR! stack: "Error: EPERM: operation not permitted, open 'C:\\Program Files\\nodejs\\npm_cache\\_
cacache\\tmp\\2f17465b'",
npm ERR! errno: -4048,
npm ERR! code: 'EPERM',
npm ERR! syscall: 'open',
npm ERR! path: 'C:\\Program Files\\nodejs\\npm_cache\\_cacache\\tmp\\2f17465b'
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.
提供几种如下解决方案
-
使用win+x,选择命令提示符(管理员),在里面运行命令就好了。
-
如果自己本身就是管理员权限,因而无用,最后症结是缓存问题导致
需要删除npmrc文件。
强调:不是nodejs安装目录npm模块下的那个npmrc文件
而是在C:\Users\{账户}\下的.npmrc文件..
- 当然也有说用命令清除缓存的,我自己试了下没成功,上面删除文件来的更加直接彻底,关键是见效。
直接用命令清理就行,控制台输入:
npm cache clean --force