0Pricing
JavaScript Academy · Lesson

package.json, scripts, and deps vs devDeps

Understand package.json fields, define simple scripts, and know the difference between dependencies and devDependencies.

Why package.json?

Goal: Read and use package.json.

  • Key fields: name, version, type
  • scripts: run short commands
  • dependencies vs devDependencies
  • Semantic versions (caret/tilde) — beginner taste
package.json, scripts, and deps vs devDeps — illustration 1

Fields at a glance

package.json is a manifest with project info, scripts, and dependency lists.

// Emulate a minimal package.json as a JS object
const pkg = {
  name: "hello-app",
  version: "1.0.0",
  type: "module",
  scripts: {
    start: "node index.js",
    build: "echo building...",
    test: "echo tests..."
  },
  dependencies: {
    "chalk": "^5.3.0"
  },
  devDependencies: {
    "eslint": "^9.0.0"
  }
};

console.log("name:", pkg.name);
console.log("version:", pkg.version);
console.log("type:", pkg.type);
console.log("scripts:", Object.keys(pkg.scripts));
package.json, scripts, and deps vs devDeps — illustration 2

All lessons in this course

  1. package.json, scripts, and deps vs devDeps
  2. npx and semantic versioning ranges
  3. Local vs global tools, bins, and team-friendly workflows
← Back to JavaScript Academy