Sajeev Nair, nodenpm
Back

Often we find ourselves dealing with directory permissions when trying to install global node modules, and since it's getting in the way of what we were trying to do in the first place, we often go for the brute force approach and try and chown that folder and that leads to a lot of problems latter on.

Change npm's default directory to another directory

An alternative approach is to set up npm's default directory in the users home where there won't be any permission issues and there is no need to escalate to sudo for any operations.

This can be done in the following easy steps:

mkdir ~/.npm-global`
npm config set prefix '~/.npm-global
echo "export PATH=~/.npm-global/bin:$PATH" >> ~/.profile && source ~/.profile

Now when you install global modules, they will be installed in this new directory, problem solved!

© Sajeev Nair.RSS