<\/span><\/h2>\r\n\r\n\r\n\r\nFirst, log in to your Debian 11 server via SSH as the root user:<\/p>\r\n\r\n\r\n\r\n
# ssh root@IP_Address -p Port_number<\/pre>\r\n\r\n\r\n\r\nYou will need to replace \u2018IP_Address\u2018 and \u2018Port_number\u2018 with your server\u2019s respective IP address and SSH port number. Additionally, replace \u2018root\u2019 with the username of the admin account if necessary.<\/p>\r\n\r\n\r\n\r\n
Before starting, you have to make sure that all Debian OS packages installed on the server are up to date. You can do this by running the following commands:<\/p>\r\n\r\n\r\n\r\n
# apt update\r\n# apt upgrade<\/pre>\r\n\r\n\r\n\r\n<\/span>Method 1: Install Node.js and npm from Debian Repository<\/span><\/h2>\r\n\r\n\r\n\r\nThe simple and easiest way to install Node.js and npm is to install them from the Debian default repository. However, it does not contain the latest Node.js version. At the time of writing this tutorial, Node.js version 12.22.5 is included by default on Debian 11 repositories.<\/p>\r\n\r\n\r\n\r\n
Install the Node.js and npm with the following command:<\/p>\r\n\r\n\r\n\r\n
# apt install nodejs npm<\/pre>\r\n\r\n\r\n\r\nOnce both packages are installed, verify the Node.js version using the following command:<\/p>\r\n\r\n\r\n\r\n
# node -v<\/pre>\r\n\r\n\r\n\r\nYou should get the following output:<\/p>\r\n\r\n\r\n\r\n
v12.22.5\r\n<\/pre>\r\n\r\n\r\n\r\nYou can also check the npm version using the following command:<\/p>\r\n\r\n\r\n\r\n
# npm -v<\/pre>\r\n\r\n\r\n\r\nYou should get the following output:<\/p>\r\n\r\n\r\n\r\n
7.5.2\r\n<\/pre>\r\n\r\n\r\n\r\n<\/span>Method 2: Install Node.js and npm from NodeSource<\/span><\/h2>\r\n\r\n\r\n\r\nIf you want to install a different version of Node.js than the one provided in the Debian repositories, you can use this method. NodeSource maintains an APT repository and contains multiple Node.js versions.<\/p>\r\n\r\n\r\n\r\n
At the time of writing this tutorial, the NodeSource repository provides v17<\/strong>, v16<\/strong>, v14<\/strong>, and v12<\/strong> versions.<\/p>\r\n\r\n\r\n\r\nWe will install the latest LTS\u00a0 v16 <\/strong>version.<\/p>\r\n\r\n\r\n\r\nInstall the curl with the following command:<\/p>\r\n\r\n\r\n\r\n
# apt install curl<\/pre>\r\n\r\n\r\n\r\nDownload and run the Node.js installation script by running the following command:<\/p>\r\n\r\n\r\n\r\n
# curl -sL https:\/\/deb.nodesource.com\/setup_16.x | bash -<\/pre>\r\n\r\n\r\n\r\nThis will add the GPG key and Node.js repository to the APT.<\/p>\r\n\r\n\r\n\r\n
Note:<\/strong> If you want another version of Node.js\u00a0 (for example 14x,<\/strong>) you just need to change the setup_16.x<\/strong> with setup_14.x<\/strong>.<\/p>\r\n\r\n\r\n\r\nInstall the Node.js version 16.x<\/strong> by running the following command:<\/p>\r\n\r\n\r\n\r\n# apt install nodejs<\/pre>\r\n\r\n\r\n\r\nThe Node.js package contains both the node<\/strong> and npm<\/strong> binaries. Once installed, verify the installed version of Node.js with the following command:<\/p>\r\n\r\n\r\n\r\n# node -v<\/pre>\r\n\r\n\r\n\r\nYou should get the following output:<\/p>\r\n\r\n\r\n\r\n
v16.13.0\r\n<\/pre>\r\n\r\n\r\n\r\nYou can also verify the npm version with the following command:<\/p>\r\n\r\n\r\n\r\n
# npm -v<\/pre>\r\n\r\n\r\n\r\nYou should get the following output:<\/p>\r\n\r\n\r\n\r\n
8.1.0\r\n<\/pre>\r\n\r\n\r\n\r\n<\/span>Method 3: Install Node.js and npm with NVM<\/span><\/h2>\r\n\r\n\r\n\r\nNVM is also known as \u201cNode Version Manager\u201d is a script that allows you to manage multiple versions of Node.js.<\/p>\r\n\r\n\r\n\r\n
You will need to download and install NVM in your system. You can download and run the script manually with the following command:<\/p>\r\n\r\n\r\n\r\n
# curl -o- https:\/\/raw.githubusercontent.com\/nvm-sh\/nvm\/v0.37.2\/install.sh | bash\r\n<\/pre>\r\n\r\n\r\n\r\nYou will need to close and reopen the terminal to add the path to the nvm script to the current shell session.<\/p>\r\n\r\n\r\n\r\n
Verify the NVM version with the following command:<\/p>\r\n\r\n\r\n\r\n
# nvm --version<\/pre>\r\n\r\n\r\n\r\nYou should get the following output:<\/p>\r\n\r\n\r\n\r\n
0.37.2\r\n<\/pre>\r\n\r\n\r\n\r\nYou can list all Node.js versions that can be installed with NVM using the following command:<\/p>\r\n\r\n\r\n\r\n
# nvm list-remote<\/pre>\r\n\r\n\r\n\r\nThis command will show you a long list of all Node.js versions.<\/p>\r\n\r\n\r\n\r\n
Install the latest stable version of Node.js with the following command:<\/p>\r\n\r\n\r\n\r\n
# nvm install node<\/pre>\r\n\r\n\r\n\r\nYou should get the following output:<\/p>\r\n\r\n\r\n\r\n
Downloading and installing node v17.1.0...\r\nDownloading https:\/\/nodejs.org\/dist\/v17.1.0\/node-v17.1.0-linux-x64.tar.xz...\r\n############################################################################################################################################ 100.0%\r\nComputing checksum with sha256sum\r\nChecksums matched!\r\nNow using node v17.1.0 (npm v8.1.2)\r\nCreating default alias: default -> node (-> v17.1.0)\r\n<\/pre>\r\n\r\n\r\n\r\nOnce the installation is completed, verify the Node.js version with the following command:<\/p>\r\n\r\n\r\n\r\n
# node --version<\/pre>\r\n\r\n\r\n\r\nYou should get the following output:<\/p>\r\n\r\n\r\n\r\n
v17.1.0\r\n<\/pre>\r\n\r\n\r\n\r\nYou can also verify the npm version with the following command:<\/p>\r\n\r\n\r\n\r\n
# npm -v<\/pre>\r\n\r\n\r\n\r\nYou should get the following output:<\/p>\r\n\r\n\r\n\r\n
8.1.2<\/pre>\r\n\r\n\r\n\r\nIf you want to install the latest LTS version, run the following command:<\/p>\r\n\r\n\r\n\r\n
# nvm install --lts<\/pre>\r\n\r\n\r\n\r\nYou can now list all installed Node.js versions using the following command:<\/p>\r\n\r\n\r\n\r\n
# nvm ls<\/pre>\r\n\r\n\r\n\r\nYou should get the following output:<\/p>\r\n\r\n\r\n\r\n
-> v16.13.0\r\nv17.1.0\r\nsystem\r\ndefault -> node (-> v17.1.0)\r\niojs -> N\/A (default)\r\nunstable -> N\/A (default)\r\nnode -> stable (-> v17.1.0) (default)\r\nstable -> 17.1 (-> v17.1.0) (default)\r\nlts\/* -> lts\/gallium (-> v16.13.0)\r\nlts\/argon -> v4.9.1 (-> N\/A)\r\nlts\/boron -> v6.17.1 (-> N\/A)\r\nlts\/carbon -> v8.17.0 (-> N\/A)\r\nlts\/dubnium -> v10.24.1 (-> N\/A)\r\nlts\/erbium -> v12.22.7 (-> N\/A)\r\nlts\/fermium -> v14.18.1 (-> N\/A)\r\nlts\/gallium -> v16.13.0\r\n<\/pre>\r\n\r\n\r\n\r\nIf you want to switch to the current Node.js version, run the following command:<\/p>\r\n\r\n\r\n\r\n
# nvm use 17.1.0<\/pre>\r\n\r\n\r\n\r\nYou should get the following output:<\/p>\r\n\r\n\r\n\r\n
Now using node v17.1.0 (npm v8.1.2)\r\n<\/pre>\r\n\r\n\r\n\r\nIn the above tutorial, you learned three different ways to install Node.js on Debian 11 server. If you are not sure which Node.js version to install, consult the documentation of the application you are going to deploy.<\/p>\r\n\r\n\r\n\r\n
Of course, you don\u2019t have to do any of this if you use one of our Node.js VPS Hosting <\/a>services, in which case you can simply ask our expert Linux admins to set up this for you. They are available 24\u00d77 and will take care of your request immediately.<\/p>\r\n\r\n\r\n\r\nPS<\/strong>. If you liked this post please share it with your friends on the social networks using the buttons on the left or simply leave a reply below. Thanks.<\/p>\r\n","protected":false},"excerpt":{"rendered":"Node.js is an open-source and cross-platform JavaScript runtime environment built on Chrome\u2019s V8 JavaScript engine. It is designed for non-blocking, … <\/p>\n
Read More<\/a><\/p>\n","protected":false},"author":4,"featured_media":40171,"comment_status":"open","ping_status":"closed","sticky":false,"template":"","format":"standard","meta":{"footnotes":""},"categories":[1700,13],"tags":[],"yoast_head":"\nHow to Install Node.js and NPM on Debian 11 | RoseHosting<\/title>\n \n \n \n \n \n \n \n \n \n \n \n \n \n \n\t \n\t \n\t \n \n \n \n \n \n \n \n\t \n\t \n\t \n