npm/pnpm/yarn
Scripts Commands
Define and run scripts in package.json for building, testing, linting, and custom workflows. Understand lifecycle hooks, pre/post scripts, and npx for one-off execution.
9 commands
Pro Tips
Use 'npx pkg' to run a package without installing it globally. Try 'npx create-react-app' or 'npx tsx script.ts'.
Use 'npm run --silent test' to suppress npm's own output — only shows your script's output.
Chain scripts: '"build": "npm run lint && npm run compile && npm run test"' runs them sequentially.
Common Mistakes
Scripts run with node_modules/.bin in PATH. Don't install tools globally when they're in devDependencies.
Pre/post lifecycle scripts (preinstall, postinstall) run automatically and can execute arbitrary code from dependencies.