This blog will help you to understand how to install node.js
Install Node.js
First update the apt-get package lists with this command:
$ sudo apt-get update
Now install the git
package using apt-get
$ sudo apt-get install git
Please change your home directory now and download the source for Node,js with wget
command. Paste this link which will be going to download node.js for you.
$ cd ~
$ wget https://nodejs.org/dist/v4.2.3/node-v4.2.3-linux-x64.tar.gz
Now make the new directory node
and extract the tar archive it with the following commands:
$ mkdir node
$ tar xvf node-v*.tar.?z --strip-components=1 -C ./node
Since we no longer needed Node.js archive that you have just downloaded it, change your home directory and use this command rm
to delete Node.js archive:
$ cd ~
$ rm -rf node-v*
Next, we'll configure the global prefix
of npm
, where npm
will create symbolic links to installed Node packages, to somewhere that it's in your default path. We'll set it to /usr/local
with this command:
$ mkdir node/etc
$ echo 'prefix=/usr/local' > node/etc/npmrc
Now move the node
and npm
binaries to installation location via this command:
$ sudo mv node /opt/
Now change the owner of files to root:
$ sudo chown -R root: /opt/node
Now in your default path, create symbolic links of the node
and npm
binaries:
$ sudo ln -s /opt/node/bin/node /usr/local/bin/node
$ sudo ln -s /opt/node/bin/npm /usr/local/bin/npm
Node.js is installed successfully. To check it please run this command:
$ node -v
All done!.
Thanks for reading the blog
0 Comment(s)