i need to run a script with node on windows like:
HOST=www.host.com node index.js
but this showme a error like
"HOST" no se reconoce como un comando interno o externo
CodePudding user response:
What you want is to run both the set
command to set your Host
environment variable in the same line that you run your script with node
. Running two commands one after an other is possible in the command line with the &
and &&
operators.
From ss64
commandA & commandB Run commandA and then run commandB commandA && commandB Run commandA, if it succeeds then run commandB
Here, since you likely don't want to continue to executing your node script if you are unable to set the environment variable, you would likely want to opt for the &&
operator for this use case.
Final Code:
set "HOST=www.host.com" && node index.js