Node.js:是否有关于 process.env 变量的任何文档 [英] Node.js: Is there any documentation about the process.env variable

查看:72
本文介绍了Node.js:是否有关于 process.env 变量的任何文档的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我在我的程序中使用了一点process.env,这个变量似乎与我的程序无关,没有它我的应用程序也可以正常运行.

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.

那么我怎样才能充分利用process.env?有没有相关的文档或教程?

So how can I fully use the process.env? Is there any document or tutorial about it?

推荐答案

试试这个链接 http://nodejs.org/api/process.html#process_process_env

然后就可以在nodeJS中做一个小程序了:

Then you can make a small program in nodeJS:

console.log(process.env)

然后运行它

$ 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:

console.log(process.env.PWD);

哪个返回

/tmp

等等...

这篇关于Node.js:是否有关于 process.env 变量的任何文档的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆