4Geeks chosen to deliver AI education in the Bahamas alongside Harvard, Oxford, and Columbia.See more

How to install JavaScript (Node.js) on your computer

By 4Geeks

Install Node.js LTS on Windows, Mac or Linux, check that node and npm work and run your first JavaScript file outside the browser.

5 min readLast updated
Install JavaScript (Node.js) icon

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.

bash
node -v
v26.13.0

If 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

SystemEasiest wayCommand or link
WindowsOfficial installer or wingetwinget install OpenJS.NodeJS.LTS
MacOfficial installer or Homebrewbrew install node
Linuxnvmnvm install --lts
Any system, several versionsnvmInstall 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:

  1. Go to nodejs.org and download the LTS Windows installer (.msi).
  2. Run it and accept the default options. Leave npm package manager and Add to PATH checked.
  3. Close and reopen PowerShell or the terminal, then run node -v.

With winget, from PowerShell:

powershell
winget install OpenJS.NodeJS.LTS

Open 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:

bash
brew install node
node -v

brew 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:

bash
curl -o- https://raw.githubusercontent.com/nvm-sh/nvm/v0.41.0/install.sh | bash
source ~/.bashrc
nvm install --lts
node -v

You have every step in the guide to install NVM on Linux.

Check that JavaScript is installed

bash
node -v   # Node.js version, for example v26.13.0
npm -v    # npm version, the package manager that comes with Node.js

If either command says it isn't recognized, close and reopen the terminal. If it still fails, see the errors table below.

Career · AI Engineering

Your JavaScript setup is ready, now build with AI

From zero to junior AI Engineer: Python, data, AI agents and RAG with mentors and real projects.

Run your first JavaScript file

Create a file called hello.js:

javascript
const name = "Node.js";
console.log(`Hello from ${name}`);

And run it from the terminal, in the same folder:

bash
node hello.js
Hello from Node.js

You can also test code without creating a file: type node to open the interactive console (REPL), write JavaScript and press Enter. Exit with .exit or Ctrl + C twice. To run JavaScript in other places, such as the browser console or VS Code, see how to run JavaScript.

Browser or Node.js?

BrowserNode.js
Needs installingNo, it's built inYes
Where you write codeDeveloper tools console (F12) or an HTML file.js files in any editor
What it's forWeb pages, buttons, formsServers, APIs, scripts, tools like React or Vite
Has document and windowYesNo
Can read files on your computerNoYes, with fs

To learn JavaScript, the browser console is enough. To build apps, use tools from npm or follow most tutorials, you need Node.js.

Install Node.js with AI

An assistant like ChatGPT, Claude or GitHub Copilot can guide you through the installation if you tell it your system and what you see. These three prompts are ready to copy.

1. Install Node.js step by step

I use [Windows 11 / macOS / Ubuntu 24.04] and I want to install Node.js LTS to learn JavaScript.
Guide me step by step and tell me how to check that node and npm work.

2. Fix "node is not recognized"

I installed Node.js on [system], but the terminal says: [paste the error].
Explain why it happens and how to fix the PATH.

3. Choose between the installer, Homebrew and nvm

I'm going to work on [one project / several projects with different Node versions] on [system].
Should I install Node.js with the official installer, Homebrew, winget or nvm? Explain the pros and cons.
Learn with a mentor

From installing Node.js to AI applications

In the 4Geeks AI Engineering career program you start with no experience and finish with AI agents and RAG systems in your portfolio.

Common errors when installing Node.js

What you seeWhy it happensFix
'node' is not recognized as an internal or external commandWindows doesn't find Node.js in the PATH, or the terminal was open before the installClose and reopen the terminal; if it still fails, reinstall and leave Add to PATH checked
command not found: nodeOn Mac or Linux the shell doesn't find it, often after installing nvmOpen a new terminal or run source ~/.zshrc or source ~/.bashrc
node -v shows an old versionUbuntu or Debian repositories ship old versions, or there are two installsUse nvm and nvm install --lts, and check which node
npm ERR! code EACCES on global installsPermission problem in system foldersDon't use sudo npm; install Node.js with nvm
running scripts is disabled on this system in PowerShellThe execution policy blocks npm scriptsRun Set-ExecutionPolicy -Scope CurrentUser RemoteSigned
Error: Cannot find moduleYou're running node in another folder or the file name is wrongGo to the file's folder with cd and check the name
Free download

Install Node.js in a 2-page cheat sheet

Install Node.js on Windows, Mac and Linux, check node and npm, run your first file, browser vs Node.js, common errors and prompts for ChatGPT, Claude or Copilot. Free, in PDF.

Install JavaScript (Node.js) cheat sheet

2 pages · PDF · 4Geeks

  • The install steps for Windows, Mac and Linux
  • Browser or Node.js: when you need each one
  • Common errors and prompts to solve them with AI

Get it free

Your PDF right away

Frequently asked questions about installing JavaScript

Want to go from setting up your computer to building AI applications, with real projects and mentors?

See the AI Engineering program