add nodejs guide

This commit is contained in:
Lee 2023-06-26 13:04:02 +01:00
parent 08e2974b08
commit c9348035fd

66
guides/install-nodejs.md Normal file

@ -0,0 +1,66 @@
---
title: How to install NodeJS
description: How to install NodeJS on Ubuntu 22.04
published: true
date: 2023-06-26T10:57:30.081Z
tags: nodejs, ubuntu, installation, containerization, container, linux, server
editor: markdown
dateCreated: 2023-06-26T10:43:59.640Z
---
# Guide to Node.js Installation on Ubuntu 22.04
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 18 on Ubuntu 22.04.
## Prerequisites
- A system running Ubuntu 22.04
- A user account with sudo privileges
- An internet connection
## Installation Steps
Begin by updating your apt repository to ensure you have the latest package information and dependencies. Open a terminal and run the following command:
```bash
sudo apt update
```
This command will refresh the package lists and update any outdated packages on your system.
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:
```bash
sudo apt install curl
```
This command will download and install curl from the Ubuntu repositories.
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)**
```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.
Once the setup script has been executed, you can install Node.js 18 by running the following command:
```bash
sudo apt install -y nodejs
```
This command installs Node.js and its package manager, npm, using the package manager apt.
After the installation is complete, you can verify the Node.js and npm versions by running the following commands:
```bash
node --version
npm --version
```
You should see the version numbers of Node.js and npm printed in the terminal, indicating a successful installation.
Prerequisites
Congratulations! You have now installed Node.js 18 on your Ubuntu 22.04 machine. Node.js is ready to be used for developing your JavaScript applications.