Skip to content

Node.js

Node.js is the way to run JavaScript code in the command line. Let's take it step by step:

Installing Node

To install Node.js, depending on your platform:

Windows

Download and run the node.js installer.

Linux-based OS (including WSL)

Run the following commands in a bash shell:

1
2
3
curl -sL https://deb.nodesource.com/setup_10.x | sudo -E bash -
sudo apt-get install -y nodejs
sudo apt-get install -y build-essential

macOS

Run the following command in a terminal:

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

Running Node

After installing Node.js on your system, you can run node in a terminal. You will see something similar to this:

node

This is what is known as a REPL, or Read, Eval, Print Loop. It is similar to the Console tab in the browser's developer tools. Here we can run JavaScript code just like in the browser console:

node