Start learning free

LESSON 49 OF 58 · FULL-STACK: SHIPPING IT

One Command to Build, One to Start

Practice

A host that runs your shop doesn't know how it is built or started. It runs npm scripts: named commands in the "scripts" object of the root package.json. npm run <name> runs one of them. start and test are so common that npm start and npm test work without run.

For example, with this script, npm run seed would run node server/seed.js:

"scripts": {
  "seed": "node server/seed.js"
}

The shop's package.json already has dev:client, which runs npm --prefix client run dev: --prefix client runs npm in the client folder, so it runs the dev script of client/package.json. The "engines" object says which Node.js the project needs: server/db.js uses node:sqlite, which older versions don't have.

The check reads your package.json and prints what each command would run:

npm run build  →  vite build, in client/  →  client/dist/: index.html and assets/app-4f2a.js
npm start      →  node server/index.js   →  GET / 200 (index.html), GET /api/products 200
npm test       →  node --test            →  server/app.test.js: 2 tests
engines        →  node 22.x

Your task: in the root package.json, add the scripts build, start and test at the top of "scripts", then an "engines" object that asks for Node.js 22.x.


Assignment
Follow the Coding Tutorial to give the shop one command to build it, one to start it, one to test it, and the Node.js version it runs on.


Hint
JSON needs a comma between entries and none after the last one. Each new script ends with a comma, because the dev scripts follow it; the closing } of "engines" needs one too, because "dependencies" follows.


STEP 1 OF 5
    Ctrl + Enter to check