简介:In this article, we will guide you through the steps of installing Node.js and NPM on Ubuntu/Debian-based Linux systems. We will cover updating the system, installing Node.js, and finally, installing NPM.
Installing Node.js and NPM on Ubuntu/Debian is a straightforward process. Here’s a step-by-step guide to help you get started:
Step 1: Update the System
First, update your system by running the following commands:
sudo apt-get update
sudo apt-get upgrade
Step 2: Install Git, Curl, and Build Essentials
Next, install Git, Curl, and the build essentials required for compiling Node.js from source. Run the following commands:
sudo apt-get install git-core curl build-essential openssl libssl-dev
Step 3: Install Node.js
Now, let’s install Node.js. You can either install a specific version or the latest stable version. Here’s how to install Node.js:
Option 1: Install Latest Stable Version
Download and install the latest stable version of Node.js from the Node.js website or use a package manager like apt.
Option 2: Install a Specific Version
If you want to install a specific version of Node.js, you can clone the Node.js repository from GitHub and compile it from source. Here’s how to do it:
git clone https://github.com/joyent/node.git
cd node
git tag # This command will show all available versions of Node.js
git checkout vX.X.X # Replace X.X.X with the specific version you want to install.
./configure
make && make install
node -v # Check the installed version.
Step 4: Install NPM
Finally, let’s install NPM, which is the package manager for Node.js. Run the following commands:
wget https://npmjs.org/install.sh —no-check-certificate
chmod 777 install.sh
./install.sh
npm -v # Check the installed version.
That’s it! You have successfully installed Node.js and NPM on your Ubuntu/Debian system.
Note: If you encounter any issues during installation, such as dependency conflicts or compile errors, try updating your system or installing any missing dependencies before proceeding.
Remember to always stay up to date with the latest versions of Node.js and NPM to ensure compatibility with new features and security updates.
Feel free to ask any questions in the comments section below if you need further assistance with installing Node.js and NPM on Ubuntu/Debian.