LV1 · 0 XPLog in
Learning path

Lesson 5 of 6 · The Developer Rig

Node.js & npm

Node.js runs JavaScript outside the browser. npm installs code other engineers have shared.

This lesson is locked. You can read ahead, but finish earlier stops to earn progress.

Listen

Watch

Video coming soon

Read

What runs where

Your browser can run JavaScript in a page. Node.js is a runtime built around the V8 JavaScript engine that runs JavaScript outside a browser. It supplies capabilities for development tools such as local servers and package installers. It is not a database or a replacement for your editor.

Install the current LTS release from nodejs.org using the machine-setup activity. LTS means Long-Term Support: a stable supported release line. Close/reopen VS Code and its terminal afterward so PATH updates are visible.

sh
node -v
npm -v

Each command should print a version, not “command not found”. Versions can differ from example screenshots; the important check is that the supported runtime and package tool are installed. A running terminal does not automatically notice every installer change.

npm installs packages; npx executes a tool

npm is the package manager installed with Node. A package is published code: a framework, utility or command-line tool. Installing it can also run installation scripts, so use trusted package names and the publisher's instructions, not arbitrary commands copied from strangers.

A local install belongs to a project; a global install makes a command available to your user/system environment:

sh
npm install some-package
npm install -g some-cli

These are syntax examples, not instructions to install packages literally called some-package. Do not run them unchanged. Global permissions vary by installation; do not use administrator access or sudo as an automatic response to every failure.

npx runs a package-provided command. It can use a package already available locally or obtain it through npm's cache. The cache can persist: it does not necessarily “run and forget” the downloaded code. Accepting a download/run prompt means executing that package with your user's permissions.

For the course's small local static preview, from your project folder:

sh
npx serve .

The dot tells serve which folder to serve. Read any package prompt, then use the local address it prints. Keep the process running while browsing and stop with Ctrl+C. Running a local server does not publish to the internet by itself, though its printed network address may allow access from your network; do not serve a folder containing private files.

Understand the project files

A package-based project has package.json listing dependencies and scripts. npm install downloads packages into node_modules and typically writes package-lock.json with resolved versions. Keep package.json and the lockfile in Git; ignore node_modules because it can be recreated and is large.

npm run dev runs the command named dev in that specific package.json. A plain HTML folder may not have that script. If npm says “Missing script: dev”, inspect the project file and your working directory rather than reinstalling Node. Do not manually edit installed files in node_modules to implement your product.

A safe package rehearsal

In a new disposable npm-practice folder outside your studio project, run npm init -y. Inspect the generated package.json in the editor. This creates package metadata; it does not create a website or install all possible tools. For a real dependency, follow its official installation instructions and inspect the change to package.json/lockfile before committing.

For a command you already need, such as serve, predict whether it installs a project dependency or runs through npx. Confirm your actual folder and examine git status afterward. Ask an AI to explain a package command before accepting it, not to run unknown installers automatically.

Diagnose common setup failures

EvidenceCheck
node/npm not foundRestart terminal, confirm installation and PATH
Missing package.jsonWrong folder, or a plain static project with no packages
Missing scriptRead that project's scripts; don't invent a command
Download failureInternet access, package spelling and registry availability
Permission error on global installSupported installer/version-manager instructions; do not blindly elevate
Local URL unreachableServer still running, exact printed port and address

Before the setup assessment

Show your own node and npm versions, explain runtime versus package manager, locate package.json in a package project and distinguish local install, global install and npx execution. Later the SvelteKit level uses these exact ideas; you should not need to guess where to run an installation command.

Key terms

Node.js
Runs JavaScript on your computer, outside the browser.
LTS
Long-Term Support — the stable release line.
npm / npx
Install packages / run one without installing.
package.json
Lists the packages a project needs.

Summary — copy into your notes

  • Node runs JavaScript on your machine — pick LTS.
  • npm installs packages; npx runs one-offs.
  • package.json lists needs; node_modules is re-downloadable.
  • Restart terminals after installing.