Stage 6 · Lesson 2 of 8
npm and package.json
work as a pair. npm init -y creates package.json, the that lists your project's name, scripts and dependencies. npm install date-fns adds a , one your code needs to run.
npm install -D vitest adds a development-only one, such as a test tool. Both land in node_modules, which you add to .gitignore. The exact versions are pinned in package-lock.json, which you do commit.
A stranger runs npm install, or npm ci for an exact install, and gets the same versions. Put commands in the scripts section, such as "start": "node src/index.js" and "test": "vitest", so npm start and npm test work everywhere. Add "type": "module" to use import. Check that a package is maintained before adding it.
A question to check yourself, an AI practice session and 1 cheat sheet entry come when you add the roadmap to your account. Add it
Resources for this stage
Start with· follow one of these
- GitHub repoFreeProject Based Learning
Community maintained · Beginner
Follow one guided build in your language, then build your own without a guide
- BookFreeEloquent JavaScript
Marijn Haverbeke · Intermediate
Free: the project chapters (a robot, a programming language, a pixel editor) show real structure
Keep handy
Also worth your time
How to present each project: the problem, stack, challenges and results
- Build Your Own XGo deeper
When you want a harder build: a shell, a key-value store or a tiny Git, from scratch