pass variable to npm command string (not the script run by npm command) [duplicate] pass variable to npm command string (not the script run by npm command) [duplicate] docker docker

pass variable to npm command string (not the script run by npm command) [duplicate]


Yes, you can:For example (for simplicity), for the line:

"build": "tsc --project "

You can start it like so:

npm run build ./src

This will start:

> tsc --project  "./src"

And another solution (I didn't see the point without glasses :) ), more suitable for you is to prefix the name of the parameter with $npm_config_, so your line should look like this:

"build:docker": "tsc -b && sh dist.sh && docker build -t repo_name/image:$npm_config_mytag ."

And then run it as:

npm run build:docker --mytag=1.0

Watch out for =