We are committed to provide service 24 X 7

Deals, Shopping, Training, Tools

31
2.218.887,55

Cart

Quantity 123.090,00
Quantity 8.000,00

Learn how to – Install Latest Node.js & NPM on Ubuntu / Debian

Learn how to – Install Latest Node.js & NPM on Ubuntu / Debian.

Welcome to our guide on how to install Latest Node.js and NPM on Ubuntu & Debian Linux distributions. Node.js is a free and open source server-side programming language which runs on various platforms (Linux, Windows, Unix, macOS). Node.js is a JavaScript runtime built on Chrome’s V8 engine for building fast and scalable network applications.

Step 1: Add Node.js APT Repository

The most recent packages of Node.js are available on a APT repository. First, update your system and install some dependencies.

sudo apt update
sudo apt install curl dirmngr apt-transport-https lsb-release ca-certificates vim

If you want to know the latest release, check Node.js Releases page

Add Node.js LTS repository

If you want to go with the LTS versions, add APT for that version. E.g for Node.js 16.x. It will be added like this (even numbers);

### Node.js 18 LTS ###
curl -sL https://deb.nodesource.com/setup_18.x | sudo -E bash -

### Node.js 16 LTS ###
curl -sL https://deb.nodesource.com/setup_16.x | sudo -E bash -

### Node.js 14 LTS ###
curl -sL https://deb.nodesource.com/setup_14.x | sudo -E bash -

Step 2: Install Latest Node.js on Ubuntu / Debian

After adding the repository, proceed to install Node.js and NPM.

sudo apt install nodejs

You can also development tools to build native addons:

sudo apt install gcc g++ make

Confirm versions.

$ node --version
v18.2.0

$ npm --version
8.9.0

Step 3: Install Yarn package manager ( Bonus and Optional)

If you need yarn package manager, install it by running:

curl -sL https://dl.yarnpkg.com/debian/pubkey.gpg | sudo apt-key add -
echo "deb https://dl.yarnpkg.com/debian/ stable main" | sudo tee /etc/apt/sources.list.d/yarn.list
sudo apt update && sudo apt install yarn

Confirm installation.

$ yarn --version
1.22.19

Step 4: Test Node.js

Let’s create a simple Nodejs app as a test that Node.js is working.

mkdir /tmp/node-demo
cd /tmp/node-demo

initialize nodejs project with default package.json file:

$ npm init -y
Wrote to /tmp/node-demo/package.json:

{
"name": "node-demo",
"version": "1.0.0",
"description": "",
"main": "index.js",
"scripts": {
"test": "echo "Error: no test specified"" && exit 1""

31
2.218.887,55

Cart

Quantity 123.090,00
Quantity 8.000,00