I have set up an environment variable (on OSX):
export npm_package_config_test_user=user42
and a javascript file:
-- index.js --
console.log(process.env.npm_package_config_test_user);
which if I run like node index.js
provides me with the expected answer. now, with this definition in the package.json
:
"scripts": {
"start": "node index.js"
},
I can do: npm start
but when I do my environment variable value comes back as undefined
.
so 2 questions:
1) why? and 2) what do I need to set up so I can pick up the value correctly?
thanks
so what I found is that npm clears the npm_package_*
space before use, so I set the variable and it wipes it out when it runs. however, this works:
export test_user=user42
The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.