Programming foundations

Stage 6 · Lesson 2 of 8

npm and package.json

Build and ship your first projects

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 repoFree
    Project Based Learning

    Community maintained · Beginner

    Follow one guided build in your language, then build your own without a guide

  • BookFree
    Eloquent JavaScript

    Marijn Haverbeke · Intermediate

    Free: the project chapters (a robot, a programming language, a pixel editor) show real structure

Keep handy

  • Free APIs that give a small project real data to work with

Also worth your time

Mark this stage as not done?