process.env

  • process
    • global obj that provides information about, and control over, the current Node.js process.
    • As a global, it is always available to Node.js applications without using require().
  • process.env
    • property returns an object containing the user environment.
    • It is possible to modify this object, but such modifications will not be reflected outside the Node.js process
    • is the object for the environment variables set in the OS, such as
      • >windows中的环境变量
        ALLUSERSPROFILE=C:\ProgramData
        CommonProgramFiles=C:\Program Files\Common Files
        CommonProgramFiles(x86)=C:\Program Files (x86)\Common Files
        CommonProgramW6432=C:\Program Files\Common Files
        ComSpec=C:\WINDOWS\system32\cmd.exe
        GRAILS_HOME=C:\Tools\grails-3.2.3
    • set the new env variable
      • process.env.mode = 'TESTING';
        
  • why env?
    • One of the best ways to use sensitive information in open source repositories without hard-coding the information within publicly available repositories is setting environment variables.
Advertisements
This entry was posted in Nodejs. Bookmark the permalink.

Leave a Reply

Fill in your details below or click an icon to log in:

WordPress.com Logo

You are commenting using your WordPress.com account. Log Out / Change )

Twitter picture

You are commenting using your Twitter account. Log Out / Change )

Facebook photo

You are commenting using your Facebook account. Log Out / Change )

Google+ photo

You are commenting using your Google+ account. Log Out / Change )

Connecting to %s