Compiling Node.js from source is easy enough so here’s how.
Installing from a tarball
Node.js needs a few things to compile so make sure they are installed.
1 2 | |
Get the link for the latest tarball from the Source Code link on the Node.js homepage. Then download it and extract it.
1 2 3 4 5 | |
Now you can compile and install the binary. By default Node.js will be installed to /usr/local/bin/node and npm will be installed to /usr/local/bin/npm.
1 2 3 4 | |
Upgrading via a tarball
To upgrade Node.js simply download the new tarball, extract and repeat the installation process.
Installing from Git
If you plan to upgrade each time a new release comes out you may find cloning the Git repository more convenient than downloading and extracting a tarball each time.
You will need Git and the dependencies to be installed first.
1 2 | |
Using Git means that instead of downloading extracting a tarball you can just clone the repository and checkout the latest version. If you need to check the versions that are available run git tag.
1 2 3 4 | |
Now you can compile the binary as before
1 2 3 | |
Upgrading via Git
To upgrade to a new release of Node.js first pull the latest source.
1 2 3 | |
Then checkout the latest version where v.x.x.x is the version you want.
1
| |
Then follow the installation process as before
1 2 3 | |
This will upgrade Node.js and overwrite the previous version.