Update and Manage Node.js version with n
Last Updated -
Every Pagely VPS has the standard Node.js package installed from the Ubuntu repository. The package manager for Node.js is npm, which is also installed. With these two tools installed on the system, you have the control to manage specific versions in the context of your own SSH user accounts and projects. We generally do not recommend changing the version installed globally on the system.
If you require a specific version of Node.js This article will discuss how to install n, the version management library for Node.js
What you'll need
- A Pagely VPS
- An SSH user with access to your VPS
What you'll need to do
There will be seven steps
- log in
- install n
- make a custom directory
- change default prefix of version installs
- install a version
- alias the command
Step 1: log in to your server
Step 2: install n
npm install n
Step 3: make the "n" folder in your home directory
Step 4: Run export N_PREFIX to change default....
You will need to change the N_PREFIX environment variable so that the binaries are installed into your home directory. You can do this as follows:
Note: we suggest adding this to your ~/.bashrc or ~/.bash_aliases so that this change is loaded on login
Step 5: add the version you desire to the 'n' directory with the following command...
Step 6: Check to make sure this worked...
Step 7: Update PATH variable
echo 'export PATH="$HOME/n/bin:$PATH"' >> ~/.bash_aliases
Note: we suggest adding this to your ~/.bashrc or ~/.bash_aliases so that this change is loaded on login. Below is an example of this, followed by a quick test...
For further instructions, please refer to the n documentation, or...