环境变量undefined

时间:2015-01-13 10:55:07

标签: unix meteor terminal env

在学习Meteor(基于Node.js构建)

的同时,设置一个简单的开发环境

从一个简单的测试开始,在env.sh中我只有:

导出CUSTOM_VAR =“某些值”

然后在app.js中,我有:

if (Meteor.isClient) {
  console.log(Meteor.settings);
}

if (Meteor.isServer) {
  console.log('Meteor Settings:');
  console.log(Meteor.settings);

  console.log('');
  console.log('Environment Variables:');
  console.log(process.env);
  console.log(process.env.CUSTOM_VAR);
}

我得到的结果似乎是来自其他一些env.sh的变量,并且CUSTOM_VAR未定义。

一旦它达到了“某种价值”,但不会再次(并且我已经做了所有事情)

这里有完整的结果:

I20150113-02:23:27.169(-8)? Meteor Settings:  
I20150113-02:23:30.006(-8)? {}
I20150113-02:23:30.007(-8)? 
I20150113-02:23:30.007(-8)? Environment Variables:
I20150113-02:23:30.007(-8)? { VIRTUALENVWRAPPER_PROJECT_FILENAME: '.project',
I20150113-02:23:30.007(-8)?   TERM_PROGRAM: 'Apple_Terminal',
I20150113-02:23:30.007(-8)?   TERM: 'xterm-256color',
I20150113-02:23:30.008(-8)?   SHELL: '/bin/bash',
I20150113-02:23:30.008(-8)?   TMPDIR: '/var/folders/tl/pcrp79f50t1_j0v_kxzdnzyw0000gn/T/',
I20150113-02:23:30.008(-8)?   Apple_PubSub_Socket_Render: '/tmp/launch-u46zHS/Render',
I20150113-02:23:30.008(-8)?   TERM_PROGRAM_VERSION: '309',
I20150113-02:23:30.008(-8)?   OLDPWD: '/Users/mac/.meteor/packages/meteor-tool/1.0.38/meteor-tool-os.osx.x86_64',
I20150113-02:23:30.009(-8)?   TERM_SESSION_ID: '48EC052B-755D-4025-8E90-A2353211C791',
I20150113-02:23:30.009(-8)?   USER: 'mac',
I20150113-02:23:30.009(-8)?   COMMAND_MODE: 'unix2003',
I20150113-02:23:30.009(-8)?   SSH_AUTH_SOCK: '/tmp/launch-TQwj0K/Listeners',
I20150113-02:23:30.009(-8)?   __CF_USER_TEXT_ENCODING: '0x1F5:0:0',
I20150113-02:23:30.009(-8)?   Apple_Ubiquity_Message: '/tmp/launch-WV3DC1/Apple_Ubiquity_Message',
I20150113-02:23:30.010(-8)?   WORKON_HOME: '/Users/mac/Users/mac/.virtualenvs',
I20150113-02:23:30.010(-8)?   PROJECT_HOME: '/Users/mac/_DEV',
I20150113-02:23:30.010(-8)?   PATH: '/Library/Frameworks/Python.framework/Versions/2.7/bin:/usr/local/bin:/usr/bin:/bin:/usr/sbin:/sbin:/usr/local/bin',
I20150113-02:23:30.010(-8)?   VIRTUALENVWRAPPER_HOOK_DIR: '/Users/mac/Users/mac/.virtualenvs',
I20150113-02:23:30.010(-8)?   PWD: '/Users/mac/_INTRA/_APPS/Meteor_test/todos/app',
I20150113-02:23:30.010(-8)?   LANG: 'en_US.UTF-8',
I20150113-02:23:30.011(-8)?   SHLVL: '1',
I20150113-02:23:30.011(-8)?   HOME: ...
I20150113-02:23:30.011(-8)?   LOGNAME: ...
I20150113-02:23:30.011(-8)?   PORT: ...
I20150113-02:23:30.011(-8)?   ROOT_URL: 'http://localhost:3000/',
I20150113-02:23:30.011(-8)?   MONGO_URL: 'mongodb://127.0.0.1:3001/meteor',
I20150113-02:23:30.012(-8)?   MOBILE_DDP_URL: 'http://localhost:3000',
I20150113-02:23:30.012(-8)?   MOBILE_ROOT_URL: 'http://localhost:3000',
I20150113-02:23:30.012(-8)?   MONGO_OPLOG_URL: 'mongodb://127.0.0.1:3001/local',
I20150113-02:23:30.012(-8)?   APP_ID: ...
I20150113-02:23:30.012(-8)?   NODE_ENV: 'development',
I20150113-02:23:30.012(-8)?   HTTP_FORWARDED_COUNT: '1',
I20150113-02:23:30.013(-8)?   ENABLE_METEOR_SHELL: 'true' }
I20150113-02:23:30.013(-8)? undefined

这条线特别有趣:

I20150113-02:23:30.010(-8)?   PATH: '/Library/Frameworks/Python.framework/Versions/2.7/bin:/usr/local/bin:/usr/bin:/bin:/usr/sbin:/sbin:/usr/local/bin',

为什么Python文件夹中的路径?我想也许几年前我在python中建立了一个全球环境?我是这个环境的新手。如何解决这个问题?

0 个答案:

没有答案