Your Dev Environment: Terminal, Node & npm
Before you write a single route or query, you need the environment every full-stack module runs in: the terminal, the Node.js runtime, and the npm package manager. Master these and you can create a project, pull in libraries, and run your code — the loop you''ll repeat thousands of times.
The terminal: your control centre
Full-stack work happens at the command line. A handful of commands cover the basics:
pwd # where am I?
ls # list files
cd my-project # change directory
mkdir api # make a folder
node index.js # run a JavaScript file
You''ll start servers, run scripts, and install packages here — not by clicking.
Node.js: JavaScript beyond the browser
Node.js is a runtime that runs JavaScript outside the browser — on your machine and on servers. It''s why one language can cover your whole stack: the same JavaScript you''d run in a browser also powers your backend. Run a file with node index.js, or type node for an interactive REPL.
npm: the package manager
You rarely build from scratch — you stand on libraries. npm installs and manages them, driven by one file:
package.json— your project''s manifest: its name, itsscripts, and its dependencies.npm install expressadds a package (and records it inpackage.json).- Installed code lands in
node_modules/— huge, regenerable, and never committed (it goes in.gitignore). npm run <name>runs a script defined inpackage.json(e.g.npm start).
dependencies vs devDependencies. Packages your app needs at runtime (like express) are dependencies; tools you only need while developing (test runners, linters, nodemon) are devDependencies (npm install --save-dev). Keeping them separate makes production installs lean.
The everyday workflow
mkdir my-api && cd my-api # new folder
npm init -y # create package.json
npm install express # add a dependency
node index.js # run it
Clone someone else''s project and the first thing you do is npm install — it reads package.json and rebuilds node_modules/ locally.
Common pitfalls
- Committing
node_modules/. It''s enormous and machine-specific —.gitignoreit and letnpm installrebuild it. - "Cannot find module ..." after cloning. You forgot
npm install; the dependencies aren''t downloaded yet. - Version drift. The
package-lock.jsonpins exact versions so everyone installs the same tree — commit it. - Global vs local installs.
npm install -ginstalls system-wide; prefer local project installs so each project controls its own versions.
Why this is your on-ramp
Every later module — Backend Foundations, Databases, APIs, Deployment — starts with npm install and npm run. Being fluent in the terminal, Node, and npm means you spend your energy on the actual code, not fighting your tools.
