npm软件包无法安装“ npm ERR!错误:EACCES:权限被拒绝”

时间:2019-11-10 16:03:14

标签: node.js ubuntu remote-access

npm ERR! Linux 3.4.0+
npm ERR! argv "/usr/bin/nodejs" "/usr/bin/npm" "install" "lodash"
npm ERR! node v5.10.1
npm ERR! npm  v3.8.3
npm ERR! path /root/test/node_modules/.staging/lodash-9a2aabe2
npm ERR! code EACCES
npm ERR! errno -13
npm ERR! syscall rename

npm ERR! Error: EACCES: permission denied, rename '/root/test/node_modules/.staging/lodash-9a2aabe2' -> '/root/test/node_modules/lodash'
npm ERR!     at destStatted (/usr/lib/node_modules/npm/lib/install/action/finalize.js:25:7)
npm ERR!     at FSReqWrap.oncomplete (fs.js:82:15)
npm ERR!
npm ERR! Error: EACCES: permission denied, rename '/root/test/node_modules/.staging/lodash-9a2aabe2' -> '/root/test/node_modules/lodash'
npm ERR!     at Error (native)
npm ERR!  [Error: EACCES: permission denied, rename '/root/test/node_modules/.staging/lodash-9a2aabe2' -> '/root/test/node_modules/lodash']
npm ERR!
npm ERR! Please try running this command again as root/Administrator.

npm ERR! Please include the following file with any support request:
npm ERR!     /root/test/npm-debug.log

2 个答案:

答案 0 :(得分:1)

使用此命令安装

sudo npm install -g <package name> --unsafe-perm=true --allow-root

答案 1 :(得分:0)

为您的用户本地安装npm软件包,如果必须全局安装,请使用sudo。例如:

sudo npm install package -g