天天看点

npm install 报错operation not permitted, unlink

环境

  • OS是Windows10
  • Nodejs是node-v12.16.2-x64.msi
  • 修改了默认的npm仓库
npm config set prefix "E:\node-repository\node_global"
 npm config set cache "E:\node-repository\node_cache"
 npm config set registry=http://registry.npm.taobao.org
           

问题:

在执行npm install时,总是出现错误。

npm ERR! code EPERM
npm ERR! syscall unlink
npm ERR! errno -4048
npm ERR! Error: EPERM: operation not permitted, unlink ''
           
  • 使用管理员用户执行,一样出现错误。
  • npm cache clear --force, 没用
  • 修改文件夹访问权限,不好使
  • npm install 后增加 –no-optional,还是出错。
  • npm install --registry=https://registry.npm.taobao.org --no-optional 依然出错

解决:

偶然看网上提到 移除了npm-cache和npm文件夹。

试着把这两个文件都在C:\Users{用户名}\AppData\Roaming下的npm删除,执行竟然成功了。