npm scripts
command
Define custom commands in package.json that can be run with npm run. Common scripts: start, dev, build, test.
Syntax
"scripts": { "start": "node app.js" }
Example
javascript
// package.json
{
"scripts": {
"start": "node server.js",
"dev": "nodemon server.js",
"build": "webpack --mode production",
"test": "jest --coverage",
"lint": "eslint src/",
"format": "prettier --write src/"
}
}
// Run scripts
// npm start
// npm run dev
// npm test