0

I have written a shell script as below

export MONGO_DBNAME=dev-db
export MONGO_HOST=a.b.c.c.d:27017,w.x.y.z:27017
export MONGO_PORT=27017
export MONGO_USERNAME=devuser
export MONGO_PASSWORD=devpassword
export MONGO_REPLICASET=devreplicaset

babel-node email-report.js

the environment variables declared are not accessible within the node script using process.env

Can someone please help with why is this happening and how can it be resolved?

1
  • Add email-report.js to your question. Commented Sep 4, 2018 at 10:16

2 Answers 2

4

You can assign it like this also process.env.BAR = "bar"

To access in node console this process.env.BAR you will get your value "BAR"

Sign up to request clarification or add additional context in comments.

Comments

0

How are you accessing variable in your JS, its quite simple.

# ~ export DATA="HELLO"

#  ~ node
> process.env.DATA
'HELLO'

Comments

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge you have read our privacy policy.

Start asking to get answers

Find the answer to your question by asking.

Ask question

Explore related questions

See similar questions with these tags.