Sherif eldeeb
Sherif eldeeb

Reputation: 2186

install packages globally in google cloud platform

I'm trying to install some npm packages globally in google cloud platform each time the shell started.

I added these commands in $HOME/.customize_environment file.

#!/bin/sh

date -u
npm i -g @angular/cli

then, I open the file /var/log/customize_environment to see the log output from $HOME/.customize_environment

I found it executed and the date is displayed (the first line) but npm couldn't installed with this error npm command not found

npm commands are available after the cloud shell starts, so I guess the file $HOME/.customize_environment is executed before installing node.

I tried to use the full path: /usr/local/nvm/versions/node/v12.14.1/bin/npm i -g @angular/cli, but I got this error /usr/bin/env: ‘node’: No such file or directory

is there a way to automatically install npm packages globally?

Upvotes: 0

Views: 453

Answers (1)

guillaume blaquiere
guillaume blaquiere

Reputation: 75715

The path env var isn't set or active. Use the full path of NPM location like that

/usr/local/nvm/versions/node/v12.14.1/bin/npm i -g @angular/cli

Be careful. if Cloud Shell update the version of NPM the path will change.

You can also try to add your NPM (without full path) command at the end of the ~/.bashrc file.

Upvotes: 1

Related Questions