Guide: what is Node.js and how to install it

BACK

November 28th, 2022, posted in tech_stuff
by Adelina, Corina

Node.js is an open-source runtime environment that uses JavaScript and helps in server-side programming. It’s cross platform, so it works on Windows, Linux, Unix and MacOS and it’s used by a lot of popular platforms and companies.

 

It uses asynchronous programming - it’s non-blocking and has a fast execution time, plus quick run because it’s built on the Google Chrome V8 engine. So Node.js is neither a programming language or a framework, it’s an environment for Javascript and its different frameworks.

 

Node.js also has its own backend framework, called Express.js. It’s part of widely-known stacks like MEAN, MERN or MEVN.

 

NPM (Node Package Manager) - which you’ll hear lots about in this article - contains open-source downloadable libraries, a package ecosystem,  and it represents the largest software registry in the world where developers are contributing to it daily. 

 

How to Install Node.js on Mac

1. Using bash with the command

curl "https://nodejs.org/dist/latest/node-${VERSION:-$(wget -qO- https://nodejs.org/dist/latest/ | sed -nE 's|.*>node-(.*)\.pkg.*|\1|p')}.pkg" > "$HOME/Downloads/node-latest.pkg" && sudo installer -store -pkg "$HOME/Downloads/node-latest.pkg" -target "/"

2. Using Homebrew with the command: brew install node

 

How to Install Node.js on Windows

For Windows, there’s an installer you can use to download the Node.js environment:

https://nodejs.org/en/download/

 

How to Install Node.js on Linux

To install Node.js on Linux, you need to run 2 commands:

sudo apt update

sudo apt install nodejs

After downloading and installing Node.js and NPM from the installer you can check the installation and the version with the following commands: node -v and npm -v.

 

Now you can also install any npm package you need with the command:

npm install <package-name>

 

Different projects might require different versions of Node and NPM. NVM (Node Version Manager) is extremely helpful in this case by helping with managing different Node versions on your device. So NVM allows you to install different versions of Node and switch between them according to your need using the command line.

 

How to Install NVM on Windows

 

How to Install NVM on Linux and Mac

First, you should have curl installed. If you need to install it run:

sudo apt-get install curl

There are 2 options, to instal NVM using curl or using wget:

  • curl -o- https://raw.githubusercontent.com/nvm-sh/nvm/v0.39.1/install.sh | bash
  • wget -qO- https://raw.githubusercontent.com/nvm-sh/nvm/v0.39.1/install.sh | bash

To check the installation you can run nvm -v

Now you can use NVM to install different node versions or use already installed versions.

  • nvm install vA.B - to install the version you want
  • nvm use A.B - to use the node version

 

And that was it, that’s how to install Node.js and use it in your projects.


About the authors

Adelina

Artsy kid navigating the world of tech for the first time and trying to learn as much as possible about it. My biggest passions are video making, writing, and TV shows I can cry to at 2AM. I also really love IKEA.

See more articles by Adelina

Corina

I`m a junior full stack developer at UPDIVISION. I never thought I will get passionate about tech and development and now I can’t imagine a more interesting and challenging field. The new things that I get to learn on a daily basis just keep me wanting to learn more and wanting to share my knowledge with others. I always try to keep stuff fun and challenging!

See more articles by Corina