If you install the nodejs on Linux(Amazon Linux, Ubuntu) using the nodejs installer, permission problems could happen when you use Yeoman, Bower, Grunt and so on. After I tried the nodejs installation in several ways, eventually I knew the best way is to avoid using ‘sudo’ permission while installing the nodejs.
Cleanup the old nodejs
If the nodejs have been already installed in your system, you need to get rid of it as the following command.
$ sudo rm -r /usr/local/bin/node /usr/local/bin/npm /usr/local/include/node /usr/local/lib/node_modules /usr/local/share/man/man/node.1
Them, remove the
.npm folder in your account.
$ rm -r ~/.npm $ rm -r .npm
nvm download and installation
To install the nodejs without the sudo permission, nvm is neccessary. Use the following command to install the nvm in the root folder of your account .
You can use wget instead of curl.
Then, Add .nvm configuration to the .bashrc file.
$ source ~/.bashrc
Install the nodejs
the stable version of nodejs
Install the stable version of the nodejs as follows.
$ nvm install stable
Get the version of the nodejs
Check if the nodejs is installed properly.
$ node -v
Attach the result of the
node -v to
~/.bashrc. (i.e v4.0.0)
Finally, you successfully installed the nodejs without sudo permission.