13 July 2015

You need to consider permissions during node installation

http://stackoverflow.com/questions/16151018/npm-throws-error-without-sudo

(Don't hack with permissions, install node the right way)

Permissions you used when installing node will be required when doing things like writing in your npm directory (npm link, npm install -g, etc.).

You probably ran node installation with root permissions, that's why the global package installation is asking you to be root.

There is two ways to manage your node installation:

On a development machine: Install node with NVM (Node Version Manager).NVM
On a production machine: Install node directly with appropriate permissions.

NVM

On a development machine, you should not install and run node with root permissions, otherwise things like npm link, npm install -g will need the same permissions.

NVM allow you to install node without root permissions and also allow you to install many versions of node to play easily with them.. Perfect for development.

  1. Start uninstalling node (root permission will probably be required)
  2. Then install NVM following instructions on this page.
  3. Install node the proper way: $ nvm install 0.10.35 (the last version)
  4. Now npm link, npm install -g will not require you to be root anymore :D

Directly

On a production machine, you can do everything with root permissions. Node installation, packages installations, etc.

Run npm link, npm install -g, etc. with root permissions.