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

  1. A Pagely VPS
  2. An SSH user with access to your VPS

What you'll need to do

There will be seven steps

  1. log in
  2. install n
  3. make a custom directory
  4. change default prefix of version installs
  5. install a version
  6. test
  7. alias the command

Step 1: log in to your server

ssh pagelyuser@pagelyserver.vps.pagelyhosting.com


Step 2: install n

npm install n


Step 3: make the "n" folder in your home directory

mkdir ~/n


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:

export N_PREFIX=$HOME/n

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...

~/node_modules/n/bin/n 11.1.0


Step 6: Check to make sure this worked...

~/n/bin/node --version


Step 7: Update PATH variable

export PATH="$HOME/n/bin:$PATH"

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...

echo 'export PATH="$HOME/n/bin:$PATH"' >> ~/.bash_aliases


For further instructions, please refer to the n documentation, or...

n --help

Related Topics

Pagely is the Managed WordPress Hosting Platform designed to exceed the needs of media, business, and Enterprise customers alike. We help the world's biggest brands scale WordPress.

Copyright © 2006-2017 Pagely, Inc. All rights reserved.
Pagely® and WordPress® are registered trademarks.

Powered by Zendesk