dman
dman

Reputation: 11064

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

I need to have my angular app over https port 443. To do that, I need to run ng as root. However, I can not get Angular CLI to install as root. Any suggestions?

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/[email protected] 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/[email protected] postinstall: `node ./bin/postinstall/script.js`
npm ERR! spawn ENOENT
npm ERR!
npm ERR! Failed at the @angular/[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/2019-08-07T14_07_14_142Z-debug.log

Upvotes: 0

Views: 489

Answers (1)

shadowspawn
shadowspawn

Reputation: 3825

By default npm takes some steps to avoid running scripts as root. You can override this with --unsafe-perm:

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

(As an aside: you do not need to install angular as root to run your eventual service as root, but that is a longer answer with more context needed.)

Upvotes: 2

Related Questions