Most devs stop at dev, build, and start in their package.json.
But npm scripts have built-in power that replaces a lot of extra tooling:
- pre/post hooks: run checks before/after any script automatically
-
Pass args with
--:npm run test -- --watchinstead of a separate script -
run-p/run-s: parallel and serial execution cross-platform -
cross-env: set env vars that work on Windows, Mac, and Linux -
node --watch: built-in file watching since Node 18, no nodemon needed -
$npm_package_version: use package.json fields directly in scripts -
Namespaced scripts:
dev:*,build:*,db:*for self-documenting structure
Full breakdown with examples:
https://devencyclopedia.com/blog/npm-scripts-you-should-know
Top comments (0)