Skip to content

Node

nodejs.org

Node.js® is a free, open-source, cross-platform JavaScript runtime environment that lets developers create servers, web apps, command line tools and scripts.

Start Node Project

cd to project folder, then init npm (Node Package Manager):

npm init

Install a node package to be used in the new project:

npm install [packageName]

Run a JavaScript from file with node:

node ./index.js

Install Node Version Manager and a certain Node version

# installs nvm (Node Version Manager)
curl -o- https://raw.githubusercontent.com/nvm-sh/nvm/v0.40.0/install.sh | bash
# download and install Node.js (you may need to restart the terminal)
nvm install 20
# verifies the right Node.js version is in the environment
node -v # should print `v20.17.0`
# verifies the right npm version is in the environment
npm -v # should print `10.8.2`