0

我需要在 https 端口 443 上运行我的 Angular 应用程序。为此,我需要以ngroot 身份运行。但是,我无法让 Angular CLI 以 root 身份安装。有什么建议么?

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
4

1 回答 1

2

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

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

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

于 2019-08-07T20:40:15.600 回答