【问题标题】:Unable to install npm package || permission denied无法安装 npm 包 ||没有权限
【发布时间】:2017-05-25 12:56:06
【问题描述】:

安装 PM2 时出现以下错误。我也尝试在本地安装它,但似乎没有任何效果。请帮忙。

命令:npm install pm2 -g

anil@anil:~/Desktop/restapis$ npm install pm2 -g 
npm WARN optional SKIPPING OPTIONAL DEPENDENCY: fsevents@^1.0.0 (node_modules/pm2/node_modules/chokidar/node_modules/fsevents):
npm WARN notsup SKIPPING OPTIONAL DEPENDENCY: Unsupported platform for fsevents@1.1.1: wanted {"os":"darwin","arch":"any"} (current: {"os":"linux","arch":"x64"})
npm ERR! Linux 4.4.0-78-generic
npm ERR! argv "/usr/bin/nodejs" "/usr/bin/npm" "install" "pm2" "-g"
npm ERR! node v6.10.3
npm ERR! npm  v3.10.10
npm ERR! path ../lib/node_modules/pm2/bin/pm2
npm ERR! code EACCES
npm ERR! errno -13
npm ERR! syscall symlink

npm ERR! Error: EACCES: permission denied, symlink '../lib/node_modules/pm2/bin/pm2' -> '/usr/local/bin/pm2'
npm ERR!     at Error (native)
npm ERR!  { Error: EACCES: permission denied, symlink '../lib/node_modules/pm2/bin/pm2' -> '/usr/local/bin/pm2'
npm ERR!     at Error (native)
npm ERR!   errno: -13,
npm ERR!   code: 'EACCES',
npm ERR!   syscall: 'symlink',
npm ERR!   path: '../lib/node_modules/pm2/bin/pm2',
npm ERR!   dest: '/usr/local/bin/pm2' }
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!     /home/anil/Desktop/restapis/npm-debug.log
anil@anil:~/Desktop/restapis$ ^C
anil@anil:~/Desktop/restapis$ sudo chmod 777 /lib/node_modules/pm2/bin/pm2
chmod: cannot access '/lib/node_modules/pm2/bin/pm2': No such file or directory
anil@anil:~/Desktop/restapis$ x

【问题讨论】:

    标签: node.js npm npm-install pm2


    【解决方案1】:

    您正在尝试将 PM2 安装为 /usr/local/bin/pm2,并且您需要 root 访问权限。

    代替:

    npm install pm2 -g 
    

    你需要:

    sudo npm install pm2 -g
    

    请注意,您需要在 sudoers 组中。

    或者,您可以将 Node 安装在您的主目录而不是系统范围内,然后您就不需要 sudo 来替换 install -g

    【讨论】:

    猜你喜欢
    • 1970-01-01
    • 2020-03-06
    • 1970-01-01
    • 1970-01-01
    • 1970-01-01
    • 2015-01-05
    • 1970-01-01
    • 2014-07-02
    • 2017-12-12
    相关资源
    最近更新 更多