After fiddling around and not exactly knowing why some ways worked and others not, I believe the following instructions are quite fool-proof. I have successfully tested it on an Amazon EC2 Ubuntu instance as non-Root user.
These steps helped me to avoid conflict caused by the $NODE_PATH variable and it’s interferences with the native environment variable of npm .
The NodeJS and NPM packages in the Ubuntu 14.04 repository can not be used because they are outdated.
Follow the instructions from the NodeJS Website:
curl -sL https://deb.nodesource.com/setup_6.x | sudo -E bash -
sudo apt-get install -y nodejs
- Optional: install build toolsTo compile and install native addons from npm you may also need to install build tools:
sudo apt-get install -y build-essential
sudo npm install -g npm (to update npm)