Installing Nodejs + NPM Without Root

I have an account on a shared Linux server that allows me to SSH into the server. My account on the server does not have root or sudo privileges. The server also does not have Nodejs or NPM installed onto it, so doing any sort of web development work is difficult. Most modern front end web development requires NPM.

After some searching, I was able to find a fairly simple way of installing Nodejs and NPM without needing root access. This was done on an up to date Ubuntu Linux server. This was a remote server, so everything was done on the command line, through SSH.

First I SSH'd into the server

ssh [email protected]

Once loged in, I downloaded the latest version of Nodejs from https://nodejs.org/dist/latest/.

wget https://nodejs.org/dist/latest/node-v7.3.0-linux-x86.tar.gz

If you are unsure which version to download you can run the uname -m command, which should tell you a bit about what you are running.

$ uname -m x86_64

The above shows that I want a x86 version for a 64 bit operating system.

Once the tar.gz file is download, you will want to extract it somewhere in your home directory. To extract a tar.gz file you run

tar -zxvf node-v7.3.0-linux-x86.tar.gz

This creates a node-v7.2.1-linux-x86 directory, which has a bin/ folder inside of it. NPM is located within this bin/directory. Now you will want to create a bash alias for this bin file so that when running an npm command from the linux command line Linux will know where to find the npm file.

alias npm="/home/user/node-v7.2.1-linux-x86/bin/npm"

Make sure that you give the correct path to the bin/npm file.

I also went ahead and edited by '.bashrc' file to include the above line. This way th alias is always there.

Now all that is left is to run NPM commands from the Linux command line. To do this I type

$(npm bin)/COMMAND

where COMMAND is the command I wish to run. To test this you can see which version of npm you have running.

$(npm bin)/npm -v 4.0.5

You should be able to run most NPM commands like this, including 'npm install', etc.