October 9th, 2024, posted in for_founders
by Miruna
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
- Click on the Download Now button from https://github.com/coreybutler/nvm-windows#readme
- Install the .exe file of the latest release by downloading the
nvm-setup.exe
and complete the steps of the installation
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 wantnvm 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.