Questions

Forum Navigation
Please to create posts and topics.

Downgrade nodejs when needed using CLI

Need to install, using npm (NodeJS Package Manager), a package, but it requires a lower version of nodejs. How to downgrade nodejs directly without purging all the stuff from the system (Linux)?

To downgrade the nodejs version on a Linux-based system we can use n for node's version management. Here the normal approach we could use with n:

Let's begin determining our Node version:

node -v // or node --version
npm -v // npm version or long npm --version

Ensure that we have n installed on the system:

sudo npm install -g n // -g for global installation

Let's upgrade n to the latest stable version:

sudo n stable

Now let's change to a specific version (we can find the version we want by checking on the official nodejs repository: http://nodejs.org/dist/

sudo n 10.16.0

If we are working on Windows platforms, we can use Cholatey to manage the nodejs package with the following approach also; to handle our node installation we need choco, that is a great CLI for provisioning a ton of popular software on Windows (similar to apt-get or yum for Linux systems).

choco install nodejs --version $VersionNumber

And if we already have it installed via chocolatey we can do the following:

choco uninstall nodejs
choco install nodejs --version $VersionNumber

For example:

choco uninstall nodejs
choco install nodejs --version 12.9.1