codegurukool.com · Free coding tutorials & online compiler

Home › Node.js Tutorial › Node.js installation

Node.js installation

Full step-by-step installation for Windows, macOS and Linux.

Windows

  1. Open nodejs.org and download the LTS installer (.msi).
  2. Run it and click Next: accept the license, keep the default folder and keep Add to PATH.
  3. Click Install and then Finish.

macOS

  1. Download the LTS .pkg installer from nodejs.org and run it. Or run brew install node.

Linux (Ubuntu or Debian)

  1. Run sudo apt update.
  2. Run sudo apt install nodejs npm. For the newest version use nvm (github.com/nvm-sh/nvm) and run nvm install --lts.

Check the installation

  1. Open a new terminal.
  2. Run node -v and then npm -v. Both should print a version.

Run your first program

  1. Save the code from the editor below as app.js.
  2. In the terminal, go to its folder and run node app.js.
  3. To start a project, run npm init -y. It creates a package.json file.

If something goes wrong

Example code

console.log("Node.js is installed");

Run this code in the online editor

← Node.js introductionNode.js get started →