Closed w3jimmy closed 7 years ago
What platform are you running this on? The syntax is different on Windows
SET CUSTOM_DEBUG=true
SET ROOT_URL=http://localhost:8080
SET MONGO_URL=mongodb://localhost:27017/test
npm start
To do that in your start script do something like
{
"start": "SET CUSTOM_DEBUG=true && SET ROOT_URL=http://localhost:8080 && SET MONGO_URL=mongodb://localhost:27017/test && node ../../main"
}
That works in cmd
and PowerShell, but won't work the same if you are using the
Git Shell.
It's also worth checking out cross-env if you need this to work in multiple environments.
thanks @fiveisprime. I'm running in Mac OS X. I will try this approach in the next few minutes
Ahh, on OSX, it looks like this
{
"start": "CUSTOM_DEBUG=true ROOT_URL=http://localhost:8080 MONGO_URL=mongodb://localhost:27017/test node ../../main"
}
This is still not working for me. location: bundle/programs/server/
I tried:
1.
CUSTOM_DEBUG=true ROOT_URL=http://localhost:8080 MONGO_URL=mongodb://localhost:27017/test node ../../main
2.
CUSTOM_DEBUG=true ROOT_URL=http://localhost:8080 MONGO_URL=mongodb://localhost:27017/test && node ../../main
3.
export CUSTOM_DEBUG=true ROOT_URL=http://localhost:8080 MONGO_URL=mongodb://localhost:27017/test && node ../../main
In all of the cases only CUSTOM_DEBUG is not being detected by the app
what could I be missing?
That first one is correct. How are you testing for CUSTOM_DEBUG
in your app?
I finally made it work, but only using cross-env.
Inside my app I access to it with process.env.CUSTOM_DEBUG
Weird, but glad you got it working!
Hi, I'm trying to pass env variables to the deployed app but I'm not succeeding.
I can deploy the app and run using the required server variables (
ROOT_URL
,MONGO_URL
,PORT
) butI have a few "switches" in my app where the code changes depending on a few server variables, for example:CUSTOM_DEBUG=true
andAPI_HOST=xxx.xxx.xxx.xxx
Is there a way to do this? And what is the correct way of doing so?
I've tried editing the final
npm start
script but didn't make any difference. Thanks