How to install the previous version of Node and npm?
Installing a specific version of Node.js and npm can be essential for compatibility reasons or to work with legacy projects. In this guide, we’ll go through the steps to install an older version of Node.js and npm on your system.
What is NodeJS?
Node is a JavaScript runtime(server-side) built on the V8 JavaScript engine of Google Chrome. It was developed in 2009 by Ryan Dhal. Node.js uses an event-driven, non-blocking input/output model, making it lightweight and efficient. It is perfect for data-intensive real-time applications. Node is like a wrapper around the V8 with built-in modules providing many features that are easy to use in asynchronous APIs.
Prerequisites
Before proceeding, ensure that you have the following prerequisites:
- Node.js and npm: Make sure you have Node.js and npm installed on your machine. If not, download the latest stable version from the official Node.js website.
NPM (Node Package Manager)
NPM (Node Package Manager) is bundled with Node.js and automates package and dependency management for Node.js projects. By running “npm install,” users can instantly fetch and install project dependencies. It enables version control to prevent project disruptions and ensures seamless onboarding for new contributors.
Steps to Install the previous version of NodeJS and NPM
Follow these steps to install a specific Node.js version in windows as well as linux:
Step 1: Check the installed version of Node and NPM on the computer use the following command respectively
- In windows:
node -v and npm -v
- In linux:
node --version and npm --version
Step 2: For installing the previous version of Node use the following command:
- In windows:
npm install -g node@version
Example:
npm install -g node@10.9.0
- In linux:
sudo apt-get install nodejs=version-1chl1~precise1
Example:
sudo apt-get install nodejs=10.9.0-1chl1~precise1
Step 3: To install previous version of NPM use the following command:
- In windows:
npm install -g npm@version
Example:
npm install -g npm@4.0.0
- In linux:
sudo apt-get install npm=version-1chl1~precise1
Example:
sudo apt-get install npm=4.0.0-1chl1~precise1
Conclusion
By following these steps, you can easily install a previous version of Node.js and npm. Remember to choose the version that best works for your project requirements.