Home › Node.js Tutorial › Node.js installation
Node.js installation
Full step-by-step installation for Windows, macOS and Linux.
Windows
- Open
nodejs.organd download the LTS installer (.msi). - Run it and click Next: accept the license, keep the default folder and keep Add to PATH.
- Click Install and then Finish.
macOS
- Download the LTS .pkg installer from
nodejs.organd run it. Or runbrew install node.
Linux (Ubuntu or Debian)
- Run
sudo apt update. - Run
sudo apt install nodejs npm. For the newest version use nvm (github.com/nvm-sh/nvm) and runnvm install --lts.
Check the installation
- Open a new terminal.
- Run
node -vand thennpm -v. Both should print a version.
Run your first program
- Save the code from the editor below as
app.js. - In the terminal, go to its folder and run
node app.js. - To start a project, run
npm init -y. It creates apackage.jsonfile.
If something goes wrong
'node' is not recognized: close and reopen the terminal, or reinstall Node.js.- Permission errors with global packages: do not use sudo, install Node.js with nvm instead.
Example code
console.log("Node.js is installed");