Setting Up Node.js

So far, all of our JavaScript has run inside a web browser. Node.js lets you run JavaScript on your own computer, in a terminal, which is what we need to write servers. This page walks you through installing it.

Follow the section for your computer (Mac or Windows), then everyone does Check That It Works.

Mac

  1. Install Node.js
    Go to nodejs.org and download the LTS version. Open the .pkg file and click through the installer with the default options. It will ask for your Mac's password.
  2. Restart VS Code
    Quit VS Code completely (Code > Quit Visual Studio Code, or Cmd+Q), then open it again. A terminal that was already open before you installed Node won't know about it.
  3. Open a terminal in VS Code
    Terminal > New Terminal. This is the terminal we'll use in class.

Windows

On Windows, we'll all use Git Bash as our terminal (not PowerShell or Command Prompt). It uses the same commands as a Mac, so everything in class will work the same for everyone.

  1. Install Git for Windows (this includes Git Bash)
    Go to git-scm.com/downloads/win and download the installer. Run it and click Next through every screen, keeping the default options. If you've already installed it before, you can skip this step.
  2. Install Node.js
    Go to nodejs.org and download the LTS version (the .msi file). Run it and keep the default options, with one exception: on the screen called Tools for Native Modules, leave the box unchecked. That box installs a lot of extra tools we don't need and can take a very long time.
  3. Restart VS Code
    Close every VS Code window, then open it again. A terminal that was already open before you installed Node won't know about it.
  4. Make Git Bash your terminal in VS Code
    Press Ctrl+Shift+P, type Terminal: Select Default Profile, press Enter, and choose Git Bash. If Git Bash isn't in the list, restart your computer and try again.
  5. Open a terminal in VS Code
    Terminal > New Terminal. The dropdown in the top right corner of the terminal panel should say bash. If it says powershell or cmd, close that terminal (the trash can icon) and open a new one.

Check That It Works (Everyone)

  1. Check the versions
    In the VS Code terminal, type each of these and press Enter:
    node -v
    npm -v
    Each one should print a version number, like v24.11.0 and 11.6.2. Your numbers might be a little different, and that's fine.
  2. Run your first Node program
    In VS Code, open your csc336-fall2026 folder (File > Open Folder). Make a new file in it called hello.js with this one line:
    console.log("Hello from Node!");
    Save it, then in the terminal type:
    node hello.js
    If you see Hello from Node! printed in the terminal, you're all set. That was JavaScript running on your computer, with no browser involved. You can delete hello.js afterward.

Terminal Commands You'll Use

These work the same on a Mac and in Git Bash.