Install node.js locally on Linux

Please note: This article is only available in English.
Installing node.js without root privileges is possible with a few tweaks.

In the last months I did all my scripting on Linux exclusively with JavaScript. For using JavaScript as my primary terminal and general scripting language I installed node.js. This basically uses Google's V8 compiler to make something useful out of JavaScript.

One of the big advantages for me is that I can glue programs that are written in C/C++ with JavaScript. Since V8 is written in C++ it is quite easy to make a JavaScript API out of an existing C++ program. Also the classical way of calling programs with command line arguments and parsing the output works great with node.js.

One problem I face on my University's computer is that I do not have root rights and the space in the (synchronized) home directory is quite small. Installing node.js is not possible without exceeding my quote. So I had to install it locally!

In the following I assume that you want to install node.js to /temp_local/node. If that is not correct then replace it by a different directory name!

Let's start by doing some initial configuration:

echo 'root    = /temp_local/node/lib/node_modules' >> ~/.npmrc
echo 'binroot = /temp_local/node/bin' >> ~/.npmrc
echo 'manroot = /temp_local/node/share/man' >> ~/.npmrc

Now we create the directory where we will install node.js and go to the parent directory of this one.

mkdir /temp_local/node
cd /temp_local

In the next step we download the latest version of node.js and extract it. After the installation we could also remove the directory, but it is always good to keep the source.

curl http://nodejs.org/dist/node-latest.tar.gz
tar xf node-latest.tar.gz
cd node-latest

Finally we are ready for the installation. The most important part is to get the prefix argument right.

./configure --prefix=/temp_local/node
make
make install

After the installation we just have to do some configuration like setting up the right lookup directory or exporting the path to node.

ln -s /temp_local/node/lib/node_modules ~/.node_modules
echo 'export PATH=/temp_local/node/bin:$PATH' >> ~/.bashrc

That's it!

Created .

References

Sharing is caring!