Lesson content
Read, practise, then check your understanding
package.json declares metadata, module entry points, scripts, engines, and dependencies. Regular dependencies are required at runtime; dev dependencies support development/build workflows; peer dependencies express compatibility with a host package.
Reproducible commands
{
"scripts": { "start": "node src/index.js", "lint": "eslint ." },
"engines": { "node": ">=22" }
}
Scripts can read package metadata through ordinary JavaScript when runtime behavior depends on it:
import manifest from "./package.json" with { type: "json" };
console.log(`${manifest.name}@${manifest.version}`);
Use npm install to update dependency intent and lockfile; npm ci installs exactly from a compatible lockfile. Semantic versions communicate breaking, feature, and patch changes, while range symbols allow updates. Review install scripts and package provenance, audit vulnerabilities in context, remove unused packages, and never publish secrets.
Knowledge check
Answer every question correctly to complete this chapter.
0 of 10 checks passed
Your progress is saved on this device.