Npm install vs sudo npm install -g

for some packages I need to run sudo npm install -g, but for others it npm installwill be enough.

Why and what is the difference?

For example:

npm install -g grunt-cli  # doesn't work
sudo npm install -g grunt-cli  # works
npm install websocket-stream # works

Is it required sudoonly with a flag -g?

+4
source share
5 answers

npm , .. node_modules . , . . Isaac ( ), , npm .

, , grunt-cli, mocha json. , , -g.

, sudo , . .

+11

-g , .

sudo, , .

+1

npm install -g grunt-cli , . -g . root, sudo -g. npm -g, , sudo . .

0

grunt-cli , PATH, , , root-.
. npm, sudo npm.

websocket-stream - , , , ​​ node_modules.

0

. -g ( "root" ), root :

sudo chown -R `whoami` ~/.npm
0

All Articles