how to use npm scripts
{
"name": "some-project",
"version": "1.0.0",
"scripts": {
"foo": "echo foo",
"multiple-commands": "echo 1; echo 2",
"using-pipe": "cat /etc/passwd | grep home",
"parent": "npm run child",
"prechild": "echo <PRE>CHILD",
"child": "echo CHILD",
"postchild": "echo <post>CHILD",
"using-node": "node -e \"console.log('from NodeJs')\"",
"complex-command": "./bin/complex-command"
}
}
Write a package.json or run npm init
to generate it and fill its scripts
property.
npm run foo
npm run bar
npm run foo -- abc 123