Sunday, October 26, 2014

NodeJS permission issues troubleshooting path

It was such a terrifying experience to have node and especially yeoman not work because of weird permission issues. I fixed the issues finally and kind of think there's pattern to it. This is not a full and final cookbook type of thingy but you might wanna check this method out in case you are stuck with the same issues. First of all
1. If the problem is not in your project directory then it must me in your ~/.config and ~/.npm directories. As you may have seen many newbies of node opt to the sudo method of installing things. But this causes problem regarding permission when yeoman comes in as some of the commands need access to areas where root is not permitted and if you do not use sudo before yo, you get errors about some of the errors where you need root. This mess up is simply caused by sometimes using sudo and sometimes not. Which you have to do because you do not own the ~/.npm directory. Just own it using
sudo chown -R `whoami` ~/.npm
2. If the problem still persists, check your project directories node_modules directory if it has any subdirectory or file deep inside where access is needed it has root privileges required. So you can use the same owning method there too
sudo chown -R `whoami` ~/.npm
3. Always try to install non globally. This will save you a lot of trouble.

Credits: Stackoverflow [ http://stackoverflow.com/questions/16151018/npm-throws-error-without-sudo ]

No comments:

Post a Comment

Post your comment here. If you want to say something about programming problems, scripts, software etc, please try to be as descriptive as possible.

Connect Rapoo MT750S with Linux (Tested on Manjaro)

 I bought this obvious copy of MX Master 2S in hopes of having the device switching functionality along with a lightweight body because I ha...