docs/guides/ubuntu/pages/22_04/install-nodejs.md

67 lines
2.4 KiB
Markdown
Raw Permalink Normal View History

2023-06-26 12:04:02 +00:00
---
title: How to install NodeJS
description: How to install NodeJS on Ubuntu 22.04
published: true
2023-06-26 12:14:19 +00:00
date: 2023-06-26T13:04:30.081Z
2023-06-28 20:22:49 +00:00
tags: nodejs, ubuntu, installation, linux, server, ubuntu, ubuntu 22.04
2023-06-26 12:04:02 +00:00
editor: markdown
2023-06-26 12:14:19 +00:00
dateCreated: 2023-06-26T13:04:59.640Z
2023-06-26 12:04:02 +00:00
---
# Guide to Node.js Installation on Ubuntu 22.04
2023-06-26 12:06:03 +00:00
Node.js is a popular open-source JavaScript runtime built on Chrome's V8 JavaScript engine. It allows you to build scalable and high-performance server-side applications using JavaScript. This guide will walk you through the installation process of Node.js on Ubuntu 22.04.
2023-06-26 12:04:02 +00:00
## Prerequisites
- A system running Ubuntu 22.04
- A user account with sudo privileges
- An internet connection
## Installation Steps
2023-06-26 12:34:42 +00:00
- Begin by updating your apt repository to ensure you have the latest package information and dependencies. Open a terminal and run the following command:
2023-06-26 12:04:02 +00:00
```bash
sudo apt update
```
This command will refresh the package lists and update any outdated packages on your system.
2023-06-26 12:34:42 +00:00
- Install the curl utility if it's not already installed. curl is used to transfer data to or from a server using various protocols. Execute the following command in the terminal to install it:
2023-06-26 12:04:02 +00:00
```bash
sudo apt install curl
```
This command will download and install curl from the Ubuntu repositories.
2023-06-26 12:34:42 +00:00
- Now, you can proceed with the installation of Node.js. Run the following command in the terminal to download and execute the Node.js setup script: **(replace "version" with the version you want to install, e.g. 18)**
2023-06-26 12:04:02 +00:00
```bash
curl -fsSL https://deb.nodesource.com/setup_version.x | sudo -E bash -
```
This command fetches the setup script from the NodeSource repository and pipes it to the bash shell with elevated privileges (sudo), allowing it to modify system files.
2023-06-26 12:34:42 +00:00
- Once the setup script has been executed, you can install Node.js by running the following command:
2023-06-26 12:04:02 +00:00
```bash
sudo apt install -y nodejs
```
This command installs Node.js and its package manager, npm, using the package manager apt.
2023-06-26 12:34:42 +00:00
- After the installation is complete, you can verify the Node.js and npm versions by running the following commands:
2023-06-26 12:04:02 +00:00
```bash
node --version
npm --version
```
You should see the version numbers of Node.js and npm printed in the terminal, indicating a successful installation.
2023-06-26 12:04:27 +00:00
## Finished
2023-06-26 12:04:02 +00:00
2023-06-26 12:06:03 +00:00
Congratulations! You have now installed Node.js on your Ubuntu 22.04 machine. Node.js is ready to be used for developing your JavaScript applications.