Browserless JavaScript

Some web developers loved JavaScript so much that they decided to make it available as a general-purpose scripting language. The result is Node.js, which has grown to become a comprehensive ecosystem for developing applications with JavaScript. It combines Google's V8 engine (which interprets and runs JavaScript at very high speeds), custom libraries for interacting with the operating system, and a web-based platform for sharing libraries with others.

Node.js applications are not run inside a web browser. There is no DOM. You will not be making calls in a Node.js script to getElementById, createElement, appendChild, or any of the other functions that deal with elements. Instead you write systems-level code. You create sockets. You read and write files. You manage processes. You receive command-line arguments.

You have several options for installing Node.js. One option is the official installer from, which installs Node.js at a system-wide level. Making it available for all users sounds like a reasonable feature, but this practice conflicts with the spirit of many Node.js projects. Maintainers of Node.js projects typically use specific versions of the libraries they depend on to avoid compatibility issues. Libraries in the Node.js ecosystem tend to get updated frequently. If you have dependencies installed at a global level, then your projects will constantly be vulnerable to the churn of updates.

If you are using an operating system with a builtin terminal, like macOS or Linux, you will experience less pain if you use a Node version manager like NVM. You install NVM with this command:

curl -o- | bash

The installer tries to add these lines to your shell's configuration file:

export NVM_DIR="$([ -z "${XDG_CONFIG_HOME-}" ] && printf %s "${HOME}/.nvm" || printf %s "${XDG_CONFIG_HOME}/nvm")"
[ -s "$NVM_DIR/" ] && \. "$NVM_DIR/" # This loads nvm

Verify that these lines are in your shell's configuration file. That file might be ~/.bash_profile, ~/.zshrc, ~/.profile, or ~/.bashrc. If you can't find these lines, add them yourself.

For this configuration to take effect, you restart your terminal. These commands install the latest version of Node.js and verify that the installation succeeded:

nvm install node
node --version

What happens you run the node interpreter without any command-line arguments?