Search code examples
npmarguments

Call npm script from another script and pass arguments


Let's say I have two scripts defined in my package json:

"script-a": "npm run script-b",
"script-b": "ts-node ./src/the-script.ts",

Let's say script-b accepts an argument logging. So I could do the following

npm run script-b --logging

Is it somehow possible to call script-a but pass the argument logging to the call of script-b. Looking like this:

npm run script-a --logging

Solution

  • I'm not sure if I understand correctly what you want to do, but you can pass arguments like this

    npm run script-a -- --logging