node.js - How to access environment variables from `npm start`? -


i have set environment variable (on osx):

export npm_package_config_test_user=user42 

and javascript file:

-- index.js -- console.log(process.env.npm_package_config_test_user); 

which if run node index.js provides me expected answer. now, definition in package.json:

  "scripts": {     "start": "node index.js"   }, 

i can do: npm start when environment variable value comes undefined.

so 2 questions:

1) why? , 2) need set can pick value correctly?

thanks

so found npm clears npm_package_* space before use, set variable , wipes out when runs. however, works:

export test_user=user42 

Comments

Popular posts from this blog

java - nested exception is org.hibernate.exception.SQLGrammarException: could not extract ResultSet Hibernate+SpringMVC -

sql - Postgresql tables exists, but getting "relation does not exist" when querying -

asp.net mvc - breakpoint on javascript in CSHTML? -