Skip to content

How to install nodejs in ubunutu?

Rupesh Bhochhibhoya edited this page Feb 17, 2016 · 1 revision

Couple of things to note about nodejs installation/configuration in ubuntu.

Basically you will find two ways.

  1. Using apt-get: for v5.x

  2. Using n module: this is a bit weird because you need to have nodejs and npm already. So, this method can be use to upgrade your nodejs or have multiple versions of nodejs

    • Assuming you already have nodejs and npm, perhaps olders version, else just run: sudo apt-get install nodejs
    • sudo npm cache clean -f
    • sudo npm install -g n
    • sudo n stable ( or you can specify the specific version, like sudo n 4.0.0)
    • sudo ln -sf /usr/local/n/versions/node//bin/node /usr/bin/node
    • node -v

when installing nodejs using apt-get, it installs the nodejs at /use/lib/nodejs and all global modules including npm at /usr/lib/node_modules folder. However when installing/upgrading npm, it installs the nodejs at /usr/local/n/versions/node/ and global node_modules including npm at /usr/local/lib/node_modules