Typorithm · easy

package.json & scripts

npm-scriptsnodejsmanifestscriptsdependencies
Saved on this device
Full lesson · 8 learning steps Open any exercise for focused practice
1

Step 1 of 8 · intro card

Learn package.json & scripts

0%

Modules & npm

package.json is the project manifest: name and version identify it, type picks the module system, scripts maps names to shell commands run via npm run, and dependencies lists runtime packages with semver ranges.

Every Node project has a package.json — the manifest describing the package. name and version identify it, and type chooses CommonJS or ES Modules.

The scripts object maps a name to a shell command. Running npm run build executes the build entry's command, with node_modules/.bin on the PATH so local tools resolve.

dependencies lists the packages your app imports at runtime, each pinned to a semver range like ^4.19.0. npm reads this list to install the right versions.

01

name + version identify the package (semver).

02

type "module" switches .js to ES Modules.

03

scripts maps names to commands run by npm run.

{
  "name": "my-app",
  "version": "1.0.0",
  "type": "module",
  "scripts": {
    "build": "tsc",
    "test": "vitest"
  },
  "dependencies": {
    "express": "^4.19.0"
  }
}

Read the implementation

Connect each part of the code to the concept before you type.

1. Package name

name identifies the package; required to publish to a registry.

"name": "my-app"

2. Version

version follows semver (major.minor.patch).

"version": "1.0.0"

3. Module system

type set to module makes .js files ES Modules instead of CommonJS.

"type": "module"

4. A script

Each scripts entry maps a name to a shell command run by npm run.

"build": "tsc"

5. A dependency

dependencies lists packages your app needs at runtime, with a semver range.

"express": "^4.19.0"

A complete learning loop

01

Understand

Read the concept map and follow the code breakdown.

02

Reconstruct

Type the implementation, repair mistakes and work through every recall exercise.

03

Verify

Use the final check without hints; revisit weak concepts in short practice sessions.

package.json & scripts: Lesson & Practice · Typorithm | ApplyDjinn