Beginner Fundamentals

Installing Node.js

Before writing code you need Node.js installed on your computer. Installing it also gives you npm, the package manager used to add libraries.

Installing Node

  • Download the installer from the official Node.js website.
  • Pick the LTS version, which is stable and recommended.
  • On macOS you can also use Homebrew, on Linux a package manager.

Check the version

After installing, open a terminal and confirm it works:

// Run these in your terminal, not inside a .js file
// node --version  -> prints something like v20.11.0
// npm --version   -> prints the npm version

If you see version numbers, the installation worked.

Run a script file

Create a file named app.js:

const name = "World";
console.log(`Hello, ${name}!`);

Then run it from the terminal:

// node app.js
// Output: Hello, World!

Summary

  • Install the LTS version of Node.js.
  • Use node --version to confirm it is installed.
  • Run any file with node filename.js.