Running Scripts in NPM
From the NPM Package Manager cheat sheet ยท Scripts & Task Running ยท verified Jul 2026
Running Scripts
Execute scripts defined in package.json
bash
# Run scripts from package.json
npm run build
npm run test
npm run dev
# Special scripts (no 'run' needed)
npm start
npm test
npm stop
npm restart
# Pass arguments to scripts
npm run test -- --watch
npm run build -- --production
# List available scripts
npm run
# Run pre/post scripts
# pretest runs before test
# postbuild runs after build๐ข Essential - Scripts automate common tasks
๐ก Use -- to pass flags to the underlying command
๐ pre/post scripts run automatically
โก Special scripts (start, test) don't need "run"
๐ Related: concurrently, npm-run-all for parallel
scriptsrun