Reputation: 15712
I have in package.json (NOT BASH, NOT SH, NOT ZSHELL, NOT FISH).
So after we established the fact that this is my package.json file, let me present it to you:
"scripts": {
"dev": "NODE_ENV=myValue myProgram"
}
I want to add more vars (e.g. MYVAR=myOtherValue
) to above file, which is my package.json file. How can I do that (adding more vars to my package.json file)?
Let me be clear that I do not want to read the manpage of bash or zshell, or fish, or sh. This is why I put the question in here and did not read the manpage - otherwise I would not put it here and would have read the manpage. Thank you for understanding.
Upvotes: 3
Views: 9169
Reputation: 66589
Your script should be:
"dev": "NODE_ENV=myValue MYVAR=myOtherValue myProgram"
as you can add multiple environment variables when space-separated.
This stems from the common behavior from terminals like bash, where you can set multiple env variables on the fly:
FOO1=baz FOO2=fnord FOO3=baz env | grep FOO
FOO1=baz
FOO2=fnord
FOO3=baz
Upvotes: 9
Reputation: 1
I am with Stevek on this one, I read the answer (the duplicate answer) and am frustrated with the references to bash. I am on a windows system that uses Powershell. I want to pass multiple environmental variables and have it work in windows systems using Powershell. Any reference to *nix commands etc unless to enable cross-system use is mudding the waters.
So far this answer is not answered. So will add what I found
This questions tells you how to pass 1 variable. How to set environment variables from within package.json
"start": "set NODE_ENV=YOURENV&&node start.js"
Now how to pass more than 1? That is still the question.
I was told that using cross-env is the best: cross-env NODE_ENV=production my-command
The answer was given here: https://github.com/kentcdodds/cross-env/issues/15
"scripts": {
"debug": "cross-env NODE_PATH=. DEBUG=app:* nodemon bootload.js"
}
However, cross-env does not use PowerShell but depreciate cmd shell on windows. So back to the main issue. [unless you make this change https://github.com/kentcdodds/cross-env/issues/192#issuecomment-513341729]
Upvotes: -1