package.json is more than a manifest — npm scripts is a small task runner with hooks, env-var injection, lifecycle stages, and parallel execution baked in. pre/post prefixes auto-bracket a task with setup/teardown; process.env.npm_package_* lets scripts read their own metadata; concurrently npm:start:* fans out a handful of related scripts in one command.
The full post collects the patterns worth knowing — pre/post hooks, env vars, cross-env, concurrently/npm-run-all, lifecycle scripts like prepublish, command-line argument forwarding via --, and when &&/& is fine vs when you actually want a task runner.
Originally published at andreasbergstrom.dev — read the full post there.
Top comments (0)