JavaScript runs in every browser, but to run it outside the browser — and to use modern tooling — you install Node.js. This guide covers running, debugging and building JavaScript in VS Code.

Install Node.js

  • All platforms: download the LTS installer from nodejs.org. This also installs npm (the package manager).
  • macOS: brew install node.
  • Linux: use nvm (nvm install --lts) so you can switch versions easily.

Verify: node --version and npm --version

Install VS Code

Install VS Code, then add ESLint (linting) and Prettier (formatting) extensions for a smoother experience. JavaScript IntelliSense is built in — no language extension needed.

Write and run

Create app.js:

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

Run it in the integrated terminal:

node app.js

Debug it

Open app.js, set a breakpoint, then press F5 and pick Node.js. VS Code attaches its debugger so you can step through, watch variables and read the call stack. For browser code, install the built-in JavaScript Debugger and launch Chrome/Edge from a launch.json.

Build / bundle

Browser projects usually bundle many files into one. Initialise a project and add a bundler:

npm init -y
npm install --save-dev vite
npx vite build

Vite (or esbuild/webpack) produces optimised, minified output in a dist/ folder ready to deploy. For Node services you typically don't bundle — you just run node and manage dependencies through package.json.