npm Scripts
Define scripts
Add entries under scripts in package.json.
{
"scripts": {
"start": "node server.js",
"dev": "node --watch server.js",
"test": "node --test"
}
}
Run them
Shortcuts: npm start and npm test need no run. Others use npm run.
npm start
npm run dev
npm test
Pass extra args
Use -- so flags reach your script.
npm run start -- --port 3000
Why scripts help
Teammates run the same named tasks without caring which tool or flag layout you chose.
Comments
One comment per signed-in account. Comments are saved with this page’s URL.