How to install Node.js with npm on Debian 10

How to install Node.js with npm on Debian 10

Install Node.js with npm on Debian 10

In this tutorial, you will learn how to install Node.js on Debian 10 using npm. Node.js is an open source JavaScript runtime environment for executing JavaScript code on the server side. Node.js is built on Chrome’s V8 JavaScript engine, so it can be used to build various types of server-side applications.

Here npm stands for Node Package Manager, the default package manager for Node.js. npm is the world’s largest software registry for Node.js packages, with thousands of packages available.

In this tutorial, you install Node.js in two ways:

  1. Install Node.js and npm using Debian repository
  2. Install Node.js and npm using nvm
  3. Install Node.js from NodeSource repository.

1. Install Node.js and npm using Debian repository

First, update the Debian apt package manager index by running the following command:

sudo apt update

Install Node.js from the Debian global repository by typing:

sudo apt install node

Enter to confirm Node.js installation

node --version

Run the following command to install npm

sudo apt install npm

Enter to confirm npm installation

npm --version

2. Install Node.js and npm using nvm

NVM stands for Node Version Manager and is used to manage multiple Node.js versions. If you want to install or uninstall a different version of Node.js, NVM is provided.

First, install NVM (Node Package Manager) on your system. Therefore, download an NVM installation script that executes the following command:

curl -o- https://raw.githubusercontent.com/creationix/nvm/v0.33.11/install.sh | bash

How to install Node.js and npm using nvm on Debian 9 How to install Node.js and npm using nvm in Debian 10

Check nvm version and confirm installation input

node --version

Install Node.js using the following command:

nvm install node

Confirm the installation of Node.js by typing

node --version

The output looks like this:

output

v10.14.0

You can install multiple versions of Node.js. To do this, enter:

nvm install 8.14
nvm install --lts
nvm install 11.3

To list all installed versions, run the following command:

nvm ls

You can change the current default version of Node.js using the following command:

nvm use 8.14

To uninstall the Node.js version, enter the following command

nvm uninstall 11.14

Install Node.js from NodeSource repository

NodeSource provides enterprise-level node support and also maintains a repository containing the latest version of Node.js.

To enable the NodeSource repository on your system, execute the following command:

curl -sL https://deb.nodesource.com/setup_10.x | sudo bash -

Note: The latest LTS version of Node.js is 10.x. Install 8.x version and just replace setup_10.x When setup_8.x

Install Node.js and npm package input.

sudo apt install nodejs

Run the following command to check the installation of Node.js and npm

node --version
npm --version

Install development tools

Run the following command to install some packages required for development

sudo apt install gcc g++ make

Uninstall Node.js and npm

Use the following command to uninstall Node.js

sudo apt remove nodejs npm
sudo apt autoremove

To uninstall the node.js version using nvm, enter the following command

nvm uninstall 10.14

Conclusion

You learned how to install Node.js on Debian 10 using npm. If you have any questions, don’t forget the comments below.

Sidebar