Friday, June 26, 2015

Installing nodejs from Source

I needed to install a software using nodejs. Unlucky for me from the apt repository I could only get nodejs version 6.something, however the latest one is 12.5 asof this moment. Hence I decided to go ahead and build it for myself from source.

The steps were the usual required for compiling any software in general.

wget  https://nodejs.org/dist/v0.12.5/node-v0.12.5.tar.gz
tar -xzvf node-v0.12.5.tar.gz
cd node-v0.12.5
./configure
make
sudo make install

However, after installing it I had no npm, which should be part of and installed along with nodejs. Seemed like node was not in my PATH so this had to be adjusted quickly.

The solution was to add /usr/local/bin/node to my PATH in ~/.profile
nano ~/.profile

And add either a new line like this:
PATH=$PATH:/usr/local/bin/node

or if you altready have a PATH defined, add this to the end
/usr/local/bin/node

Press CTRL+O to write the file and CTRL+X to close nano. Finally,
source ~/.profile

npm worked just fine after this.

No comments:

Post a Comment