sindresorhus / guides

A collection of succinct guides - Public Domain
2.47k stars 458 forks source link

"Install npm packages globally without sudo" is incompatible with nvm #43

Closed darkbasic closed 5 years ago

darkbasic commented 6 years ago

nvm says:

$ nvm install 8                                                                                                                                                                                                                         
Downloading and installing node v8.9.4...                                                                                                                                                                                                                    
Downloading https://nodejs.org/dist/v8.9.4/node-v8.9.4-linux-x64.tar.xz...                                                                                                                                                                                   
######################################################################## 100,0%                                                                                                                                                                              
Computing checksum with sha256sum                                                                                                                                                                                                                            
Checksums matched!                                                                                                                                                                                                                                           
nvm is not compatible with the npm config "prefix" option: currently set to "/home/niko/.npm-packages"                                                                                                                                                       
Run `npm config delete prefix` or `nvm use --delete-prefix v8.9.4` to unset it.
Rowno commented 6 years ago

You don't need to use that guide if you're using nvm, because nvm handles it for you (hence the compatibility warning).

darkbasic commented 6 years ago

How can I install global packages without sudo using nvm?

Rowno commented 6 years ago

You don't need to use sudo with nvm. Just npm install -g yo, nvm automatically sets the npm prefix to non-root directory. If you've been using sudo with nvm you'll probably need to fix the permissions of the nvm and npm cache directories.

sindresorhus commented 5 years ago

My recommendation is to not use nvm. It has so many problems and issues.

https://github.com/tj/n is a better choice.