执行npm install xxxx报错,npm ERR,the command again as root/Administrator

1.在vscode编辑器命令行终端中执行npm报错

报错信息如下:

PS D:\workspace\vscodeproject\nodejsstudy> npm install mysql
npm ERR! code EPERM
npm ERR! syscall open
npm ERR! path D:\tools\nodejs\node_cache\_cacache\tmp\9cdb6d6a
npm ERR! errno EPERM
npm ERR! FetchError: Invalid response body while trying to fetch http://registry.npm.taobao.org/mysql: EPERM: operation not permitted, o
pen 'D:\tools\nodejs\node_cache\_cacache\tmp\9cdb6d6a'
npm ERR!     at D:\tools\nodejs\node_modules\npm\node_modules\minipass-fetch\lib\body.js:162:15
npm ERR!     at async Arborist.[nodeFromEdge] (D:\tools\nodejs\node_modules\npm\node_modules\@npmcli\arborist\lib\arborist\build-ideal-t
ree.js:1061:19)
npm ERR!     at async Arborist.[buildDepStep] (D:\tools\nodejs\node_modules\npm\node_modules\@npmcli\arborist\lib\arborist\build-ideal-t
ree.js:930:11)
npm ERR!     at async Arborist.buildIdealTree (D:\tools\nodejs\node_modules\npm\node_modules\@npmcli\arborist\lib\arborist\build-ideal-t
ree.js:216:7)
npm ERR!     at async Promise.all (index 1)
npm ERR!     at async Arborist.reify (D:\tools\nodejs\node_modules\npm\node_modules\@npmcli\arborist\lib\arborist\reify.js:149:5)       
npm ERR!     at async Install.install (D:\tools\nodejs\node_modules\npm\lib\install.js:170:5)
npm ERR!  FetchError: Invalid response body while trying to fetch http://registry.npm.taobao.org/mysql: EPERM: operation not permitted, 
npm ERR!   type: 'system',
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! the command again as root/Administrator.可以发现该报错原因是应为权限不足,需要时Linux下的root或者windows下的Administrator权限。

2.解决方法

以管理员身份运行vscode即可解决在vscode终端中安装依赖包权限不足的问题,同理cmd下运行的也是如此。
在这里插入图片描述

Logo

腾讯云面向开发者汇聚海量精品云计算使用和开发经验,营造开放的云计算技术生态圈。

更多推荐