How to use environment variables in package.json

后端 未结 6 1780
有刺的猬
有刺的猬 2020-12-30 19:01

Because we don\'t want sensitive data in the project code, including the package.json file, using environment variables would be a logical choice in my opinion.

Exam

6条回答
  •  失恋的感觉
    2020-12-30 19:37

    You can use environment values to inject in your package.json like this:

    Any environment variables that start with npm_config_ will be interpreted as a configuration parameter. For example, putting npm_config_foo=bar in your environment will set the foo configuration parameter to bar. Any environment configurations that are not given a value will be given the value of true. Config values are case-insensitive, so NPM_CONFIG_FOO=bar will work the same.

    https://docs.npmjs.com/misc/config#environment-variables

提交回复
热议问题