HTTPS上的Angular CLI-无法以root身份安装CI

时间:2019-08-07 14:36:00

标签: npm angular-cli n

我需要在https端口443上安装我的角度应用程序。为此,我需要以root用户身份运行ng。但是,我无法将Angular CLI作为根目录安装。有什么建议么?

root@develop:~# n v9.4.0

     install : node-v9.4.0
       mkdir : /root/n/n/versions/node/9.4.0
       fetch : https://nodejs.org/dist/v9.4.0/node-v9.4.0-linux-x64.tar.gz
######################################################################### 100.0%
   installed : v9.4.0

root@develop:~# npm install -g @angular/cli
/root/n/bin/ng -> /root/n/lib/node_modules/@angular/cli/bin/ng

> @angular/cli@8.2.0 postinstall /root/n/lib/node_modules/@angular/cli
> node ./bin/postinstall/script.js

sh: 1: node: Permission denied
npm ERR! file sh
npm ERR! code ELIFECYCLE
npm ERR! errno ENOENT
npm ERR! syscall spawn
npm ERR! @angular/cli@8.2.0 postinstall: `node ./bin/postinstall/script.js`
npm ERR! spawn ENOENT
npm ERR!
npm ERR! Failed at the @angular/cli@8.2.0 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/2019-08-07T14_07_14_142Z-debug.log

1 个答案:

答案 0 :(得分:1)

默认情况下,npm采取一些步骤来避免以root身份运行脚本。您可以使用--unsafe-perm覆盖它:

# npm install -g --unsafe-perm @angular/cli 

(顺便说一句:您无需以root身份安装angular即可以root身份运行最终的服务,但这是更长的答案,需要更多的上下文。)