Friday, September 04, 2015

NPM without sudo


In development environments, access to install NPM global packages under the standard /usr path if often restricted. Instead of using sudo for global package installation, which is rarely the desired solution in development, it is possible to instruct NPM to use a directory owned by the logon user as follows:

mkdir ~/npm
npm config set prefix ~/npm

After this, installing a package globally, such as:

npm install -g async

will result int the library files being placed under the configured location (~/npm in this example).

No comments: