How do you install JavaScript on your computer?
Short answer: JavaScript itself doesn't need installing: every browser already runs it. To run JavaScript outside the browser, install Node.js. Download the LTS version from nodejs.org, or use winget install OpenJS.NodeJS.LTS on Windows, brew install node on Mac, or nvm on any system. Then check it with node -v.
node -vv26.13.0If you see a version number, Node.js and npm are installed and you can run any .js file with node file.js.
Install Node.js, check the version and run your first file.
Install Node.js: every option
| System | Easiest way | Command or link |
|---|---|---|
| Windows | Official installer or winget | winget install OpenJS.NodeJS.LTS |
| Mac | Official installer or Homebrew | brew install node |
| Linux | nvm | nvm install --lts |
| Any system, several versions | nvm | Install NVM on Windows, macOS and Linux |
Always choose the LTS (Long Term Support) version. It's the stable one that most projects and tutorials use.
Install Node.js on Windows
With the installer:
- Go to nodejs.org and download the LTS Windows installer (
.msi). - Run it and accept the default options. Leave npm package manager and Add to PATH checked.
- Close and reopen PowerShell or the terminal, then run
node -v.
With winget, from PowerShell:
winget install OpenJS.NodeJS.LTSOpen a new terminal afterwards so it picks up the new PATH.
Install Node.js on Mac
With the installer: download the LTS .pkg file from nodejs.org, open it and follow the steps.
With Homebrew:
brew install node
node -vbrew install node installs the newest version, which may be newer than the LTS. If you need an exact version, use nvm: install NVM on Mac with Homebrew.
Install Node.js on Linux
The nodejs package in Ubuntu and Debian repositories is often several versions behind. The most reliable way is nvm:
curl -o- https://raw.githubusercontent.com/nvm-sh/nvm/v0.41.0/install.sh | bash
source ~/.bashrc
nvm install --lts
node -vYou have every step in the guide to install NVM on Linux.
Check that JavaScript is installed
node -v # Node.js version, for example v26.13.0
npm -v # npm version, the package manager that comes with Node.jsIf either command says it isn't recognized, close and reopen the terminal. If it still fails, see the errors table below.
