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

More NPM tasks

Back to the full NPM Package Manager cheat sheet