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

Angular CLI on HTTPS - can't install CI as root

我需要在 https 端口 443 上运行我的 angular 应用程序。为此,我需要 运行 ng 作为 root。但是,我无法以 root 身份安装 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

默认情况下,npm 采取一些步骤来避免 运行ning 脚本作为 root。您可以使用 --unsafe-perm:

覆盖它
# npm install -g --unsafe-perm @angular/cli 

(顺便说一句:您不需要将 angular 作为 root 安装到 运行 您最终作为 root 的服务,但这是一个更长的答案,需要更多的上下文。)