sindresorhus / guides

A collection of succinct guides - Public Domain

Geek Repo:Geek Repo

Github PK Tool:Github PK Tool

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

darkbasic opened this issue · comments

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.

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

How can I install global packages without sudo using nvm?

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.

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

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