I use process.env
a little in my program, it seems this variable have nothing to do with my program, without it my app could work well, too.
我使用的过程。env一点点在我的程序中,似乎这个变量无关与我的计划,也没有它我的应用程序也可以很好地工作。
So how can I fully use the process.env
? Is there any document or tutorial about it?
那么我怎样才能充分利用这个过程呢?有相关的文档或教程吗?
1 个解决方案
#1
70
Try this link http://nodejs.org/api/process.html#process_process_env
试试这个链接http://nodejs.org/api/process.html process_process_env
Then you can make a small program in nodeJS:
然后你可以用nodeJS制作一个小程序:
console.log(process.env)
And run it
并运行它
$ node myProgram.js
{ TERM_PROGRAM: 'iTerm.app',
TERM: 'xterm',
SHELL: '/bin/bash',
CLICOLOR: '1',
TMPDIR: '/var/folders/ff/59np25p96x95hpgbtsv3r6zr0000gn/T/',
Apple_PubSub_Socket_Render: '/tmp/launch-LIiu0r/Render',
OLDPWD: '/Users/hermanjunge',
USER: 'hermanjunge',
COMMAND_MODE: 'unix2003',
SSH_AUTH_SOCK: '/tmp/launch-XOMy7j/Listeners',
__CF_USER_TEXT_ENCODING: '0x1F5:0:0',
Apple_Ubiquity_Message: '/tmp/launch-jiZQH0/Apple_Ubiquity_Message',
LSCOLORS: 'ExFxCxDxBxegedabagacad',
PATH: '/Users/hermanjunge/.rbenv/shims:/usr/local/bin:/usr/bin:/bin:/usr/sbin:/sbin:/usr/local/bin:/opt/X11/bin:/usr/local/git/bin:/usr/local/mysql/bin',
PWD: '/tmp',
ITERM_PROFILE: 'hermanjunge',
SHLVL: '1',
COLORFGBG: '7;0',
HOME: '/Users/hermanjunge',
ITERM_SESSION_ID: 'w1t4p0',
LOGNAME: 'hermanjunge',
LC_CTYPE: 'UTF-8',
DISPLAY: '/tmp/launch-HCtQeC/org.macosforge.xquartz:0',
_: '/usr/local/bin/node' }
Then, we learned that we can get elements from the environment we are running our app. Like, for example:
然后,我们了解到,我们可以从运行app的环境中获取元素。
console.log(process.env.PWD);
Which returns
它返回
/tmp
And so on...
等等……
#1
70
Try this link http://nodejs.org/api/process.html#process_process_env
试试这个链接http://nodejs.org/api/process.html process_process_env
Then you can make a small program in nodeJS:
然后你可以用nodeJS制作一个小程序:
console.log(process.env)
And run it
并运行它
$ node myProgram.js
{ TERM_PROGRAM: 'iTerm.app',
TERM: 'xterm',
SHELL: '/bin/bash',
CLICOLOR: '1',
TMPDIR: '/var/folders/ff/59np25p96x95hpgbtsv3r6zr0000gn/T/',
Apple_PubSub_Socket_Render: '/tmp/launch-LIiu0r/Render',
OLDPWD: '/Users/hermanjunge',
USER: 'hermanjunge',
COMMAND_MODE: 'unix2003',
SSH_AUTH_SOCK: '/tmp/launch-XOMy7j/Listeners',
__CF_USER_TEXT_ENCODING: '0x1F5:0:0',
Apple_Ubiquity_Message: '/tmp/launch-jiZQH0/Apple_Ubiquity_Message',
LSCOLORS: 'ExFxCxDxBxegedabagacad',
PATH: '/Users/hermanjunge/.rbenv/shims:/usr/local/bin:/usr/bin:/bin:/usr/sbin:/sbin:/usr/local/bin:/opt/X11/bin:/usr/local/git/bin:/usr/local/mysql/bin',
PWD: '/tmp',
ITERM_PROFILE: 'hermanjunge',
SHLVL: '1',
COLORFGBG: '7;0',
HOME: '/Users/hermanjunge',
ITERM_SESSION_ID: 'w1t4p0',
LOGNAME: 'hermanjunge',
LC_CTYPE: 'UTF-8',
DISPLAY: '/tmp/launch-HCtQeC/org.macosforge.xquartz:0',
_: '/usr/local/bin/node' }
Then, we learned that we can get elements from the environment we are running our app. Like, for example:
然后,我们了解到,我们可以从运行app的环境中获取元素。
console.log(process.env.PWD);
Which returns
它返回
/tmp
And so on...
等等……