linux sh: 1: node: Permission denied

问题

Linux 系统下 npm 安装报错 没有权限

1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
[email protected]:~# npm install spy-debugger -g
npm WARN deprecated [email protected]: express 2.x series is deprecated
npm WARN deprecated [email protected]: connect 1.x series is deprecated
/root/.nvm/versions/node/v8.2.1/bin/spy-debugger -> /root/.nvm/versions/node/v8.2.1/lib/node_modules/spy-debugger/lib/index.js
> [email protected] postinstall /root/.nvm/versions/node/v8.2.1/lib/node_modules/spy-debugger
> node lib/scripts/postinstall.js
sh: 1: node: Permission denied
npm ERR! file sh
npm ERR! code ELIFECYCLE
npm ERR! errno ENOENT
npm ERR! syscall spawn
npm ERR! [email protected] postinstall: `node lib/scripts/postinstall.js`
npm ERR! spawn ENOENT
npm ERR!
npm ERR! Failed at the [email protected] postinstall script.
npm ERR! This is probably not a problem with npm. There is likely additional logging output above.
npm ERR! A complete log of this run can be found in:
npm ERR! /root/.npm/_logs/2017-08-22T01_12_38_462Z-debug.log

解决

执行一下命令即可

1
npm config set unsafe-perm true

如果还不行 再执行如下

1
2
3
npm config set user 0
npm config set unsafe-perm true
sudo npm install -g sm

参考

参考