npm run script with arguments code example

Example 1: npm script with arguments

"scripts": {
	"grunt": "grunt",
	"server": "node server.js"
}
...
# here's how to pass the params to those scripts:
npm run grunt -- task:target  // invokes `grunt task:target`
npm run server -- --port=1337 // invokes `node server.js --port=1337`

Example 2: npm run command with arguments

npm run <command> [-- <args>]
ex: npm start -- --reset-cache

Example 3: npm run script with arguments

$ PORT=8080 npm start

Example 4: npm run script with arguments

"start": "node ./script.js server $PORT"

Tags:

Misc Example