process.env在WebStorm taskrunner中不起作用

时间:2016-10-06 23:04:57

标签: node.js webstorm

当我从WebStorm的任务运行程序中运行console.log(process.env) server.js时,它会打印出来:

{ npm_config_save_dev: '',
  npm_config_legacy_bundling: '',
  npm_config_dry_run: '',
  npm_package_devDependencies_compress: '^0.99.0',
  npm_package_dependencies_request: '^2.75.0',
  npm_config_viewer: 'man',
  npm_config_only: '',
  npm_config_browser: '',
  npm_package_gitHead: 'f5e970c2b4867a0194adc2d66f48aa5a5b5f9010',
  npm_package_scripts_build_d_localhost: 'webpack --config webpack.production.config.js',
  npm_config_also: '',
  npm_package_devDependencies_compression: '^1.6.2',
  npm_config_rollback: 'true',
  npm_package_devDependencies_url_loader: '^0.5.7',
  NODE: '/Users/test/.nvm/versions/node/v6.2.2/bin/node',
  npm_config_usage: '',
  npm_package_devDependencies_file_loader: '^0.8.5',
  npm_config_globalignorefile: '/Users/test/.nvm/versions/node/v6.2.2/etc/npmignore',
  npm_package_scripts_build_q: 'webpack --config webpack.production.config.js',
  npm_package_devDependencies_parse_cloud_express: '~1.0',
  SHELL: '/bin/bash',
  npm_config_shell: '/bin/bash',
  npm_config_maxsockets: '50',
  npm_config_init_author_url: '',
  npm_package_devDependencies_style_loader: '^0.13.1',
  npm_config_shrinkwrap: 'true',
  npm_config_parseable: '',
  npm_package_devDependencies_webpack_merge: '^0.8.4',
  TMPDIR: '/var/folders/d9/rjkk3ch93qlf3c1th1p0gyn40000gp/T/',
  npm_config_init_license: 'ISC',
  npm_package_dependencies_react_linkify: '0.1.1',
  Apple_PubSub_Socket_Render: '/private/tmp/com.apple.launchd.OOTWqHXJWy/Render',
  npm_config_if_present: '',
  npm_package_devDependencies_babel_core: '^6.7.4',
  npm_package_scripts_dev: 'node server.js',
  npm_config_sign_git_tag: '',
  npm_config_init_author_email: '',
  npm_config_cache_max: 'Infinity',
  npm_config_long: '',
  npm_config_local_address: '',
  npm_config_git_tag_version: 'true',
  npm_config_cert: '',
  npm_config_registry: 'https://registry.npmjs.org/',
  npm_config_npat: '',
  npm_config_fetch_retries: '2',
  npm_package_devDependencies_ejs_loader: '^0.2.1',
  npm_package_devDependencies_body_parser: '^1.15.2',
  DEBUG_FD: '1',
  npm_package_devDependencies_extract_text_webpack_plugin: '^1.0.1',
  npm_package_devDependencies_clean_webpack_plugin: '^0.1.8',
  npm_package_dependencies_react_dom: '^15.0.0',
  npm_config_versions: '',
  npm_config_message: '%s',
  npm_config_key: '',
  npm_package_readmeFilename: 'README.md',
  npm_package_dependencies_react_flip_move: '^2.4.2',
  npm_package_description: '',
  npm_package_devDependencies_webpack: '^1.12.14',
  MOCHA_COLORS: '1',
  USER: 'test',
  npm_package_devDependencies_socket_io: '^1.4.8',
  npm_package_scripts_build_d: 'webpack --config webpack.production.config.js',
  npm_config_globalconfig: '/Users/test/.nvm/versions/node/v6.2.2/etc/npmrc',
  npm_config_always_auth: '',
  npm_package_devDependencies_webpack_dev_server: '^1.14.1',
  npm_package_devDependencies_babel_loader: '^6.2.4',
  SSH_AUTH_SOCK: '/private/tmp/com.apple.launchd.B04ZXLN25F/Listeners',
  npm_package_devDependencies_request: '^2.67.0',
  __CF_USER_TEXT_ENCODING: '0x1F6:0x0:0xF',
  npm_execpath: '/Users/test/.nvm/versions/node/v6.2.2/lib/node_modules/npm/bin/npm-cli.js',
  npm_config_global_style: '',
  npm_config_cache_lock_retries: '10',
  npm_package_dependencies_flux: '^2.1.1',
  npm_config_cafile: '',
  npm_package_devDependencies_parse: '^1.6.14',
  npm_package_scripts_build_m: 'webpack --config webpack.production.config.js',
  npm_package_devDependencies_babel_preset_react: '^6.5.0',
  npm_config_heading: 'npm',
  npm_config_proprietary_attribs: 'true',
  npm_config_fetch_retry_mintimeout: '10000',
  npm_package_devDependencies_webpack_dev_middleware: '^1.8.3',
  npm_config_json: '',
  npm_config_access: '',
  npm_config_argv: '{"remain":[],"cooked":["run-script","dev:localhost"],"original":["run-script","dev:localhost"]}',
  npm_package_devDependencies_babel_preset_es2015: '^6.6.0',
  npm_package_dependencies_underscore: '^1.8.3',
  PATH: '/Users/test/.nvm/versions/node/v6.2.2/lib/node_modules/npm/bin/node-gyp-bin:/Users/test/GuichiProject/blrt-web-app-server/node_modules/.bin:/Users/test/.nvm/versions/node/v6.2.2/bin:/usr/bin:/bin:/usr/sbin:/sbin',
  npm_config_https_proxy: '',
  npm_config_engine_strict: '',
  npm_config_description: 'true',
  npm_config_userconfig: '/Users/test/.npmrc',
  npm_config_init_module: '/Users/test/.npm-init.js',
  npm_package_devDependencies_json_loader: '^0.5.4',
  npm_package_devDependencies_grunt_aws: '^0.6.1',
  npm_package_devDependencies_ejs: '^2.5.2',
  npm_package_dependencies_node_uuid: '^1.4.7',
  PWD: '/Users/test/GuichiProject/blrt-web-app-server',
  npm_config_user: '502',
  npm_config_node_version: '6.2.2',
  ELECTRON_NO_ATTACH_CONSOLE: 'true',
  npm_lifecycle_event: 'dev:localhost',
  npm_config_save: '',
  npm_config_editor: 'vi',
  npm_package_name: 'blrtwebapp',
  npm_config_tag: 'latest',
  npm_config_progress: 'true',
  npm_config_global: '',
  npm_package_scripts_start: 'node server.js',
  npm_config_optional: 'true',
  XPC_FLAGS: '0x0',
  npm_config_force: '',
  npm_config_bin_links: 'true',
  npm_package_devDependencies_express: '~4.9.x',
  npm_config_searchopts: '',
  npm_package_engines_node: 'v6.3.0',
  npm_package_dependencies_classnames: '^2.2.1',
  FORCE_COLOR: 'true',
  npm_config_depth: 'Infinity',
  npm_package_devDependencies_grunt: '^0.4.5',
  npm_config_searchsort: 'name',
  npm_config_rebuild_bundle: 'true',
  npm_package_version: '',
  XPC_SERVICE_NAME: 'com.jetbrains.WebStorm.1524',
  npm_config_unicode: '',
  npm_package_devDependencies_google_libphonenumber: '^1.0.12',
  DEBUG_COLORS: 'true',
  SHLVL: '1',
  HOME: '/Users/test',
  npm_config_fetch_retry_maxtimeout: '60000',
  npm_package_dependencies_react_script_loader: '0.0.1',
  npm_package_dependencies_fluxocket: '^1.0.0',
  npm_config_tag_version_prefix: 'v',
  npm_config_strict_ssl: 'true',
  npm_config_save_prefix: '^',
  npm_config_loglevel: 'warn',
  npm_config_ca: '',
  npm_package_devDependencies_multer: '^1.2.0',
  npm_package_devDependencies_lodash: '^4.3.0',
  npm_config_save_exact: '',
  npm_config_group: '20',
  npm_config_fetch_retry_factor: '10',
  npm_config_dev: '',
  npm_package_devDependencies_webpack_hot_middleware: '^2.12.2',
  npm_package_devDependencies_underscore: '^1.8.3',
  npm_package_dependencies_object_assign: '^4.0.1',
  npm_config_version: '',
  npm_config_cache_lock_stale: '60000',
  npm_config_cache_min: '10',
  npm_config_searchexclude: '',
  npm_config_cache: '/Users/test/.npm',
  npm_package_devDependencies_html_webpack_plugin: '^2.15.0',
  npm_package_dependencies_keymirror: '^0.1.1',
  LOGNAME: 'test',
  npm_lifecycle_script: 'node server.js',
  npm_config_color: 'true',
  npm_package_devDependencies_webpack_s3_plugin: '^0.6.7',
  npm_package_devDependencies_es6_promise: '^3.0.2',
  npm_config_proxy: '',
  npm_package_dependencies_react: '^15.0.0',
  npm_package_dependencies_parse: '^1.6.14',
  npm_config_save_optional: '',
  npm_config_ignore_scripts: '',
  npm_config_user_agent: 'npm/3.9.5 node/v6.2.2 darwin x64',
  npm_package_devDependencies_jsonfile: '^2.4.0',
  npm_config_cache_lock_wait: '10000',
  npm_package_scripts_dev_localhost: 'node server.js',
  npm_package_dependencies_react_timeago: '^3.1.1',
  npm_config_production: '',
  npm_package_devDependencies_mandrill_api: '^1.0.45',
  npm_config_save_bundle: '',
  npm_config_umask: '0022',
  npm_config_init_version: '1.0.0',
  npm_config_scope: '',
  npm_config_init_author_name: '',
  npm_config_git: 'git',
  npm_package_devDependencies_css_loader: '^0.23.1',
  npm_package_devDependencies_express_useragent: '^1.0.4',
  npm_config_unsafe_perm: 'true',
  npm_config_tmp: '/var/folders/d9/rjkk3ch93qlf3c1th1p0gyn40000gp/T',
  npm_config_onload_script: '',
  npm_package_dependencies_react_router: '^2.5.2',
  npm_node_execpath: '/Users/test/.nvm/versions/node/v6.2.2/bin/node',
  npm_config_prefix: '/Users/test/.nvm/versions/node/v6.2.2',
  npm_config_link: '',
  _: '/Users/test/.nvm/versions/node/v6.2.2/bin/node' }

如果我运行>来自WebStorm的集成终端中的process.env它给了我:

{ MANPATH: '/Users/test/.nvm/versions/node/v6.2.2/share/man:/usr/local/share/man:/usr/share/man:/Applications/Xcode.app/Contents/Developer/Platforms/MacOSX.platform/Developer/SDKs/MacOSX10.12.sdk/usr/share/man:/Applications/Xcode.app/Contents/Developer/usr/share/man:/Applications/Xcode.app/Contents/Developer/Toolchains/XcodeDefault.xctoolchain/usr/share/man',
  rvm_bin_path: '/Users/test/.rvm/bin',
  GEM_HOME: '/Users/test/.rvm/gems/ruby-2.3.0',
  NVM_CD_FLAGS: '',
  TERM: 'xterm-256color',
  SHELL: '/bin/bash',
  IRBRC: '/Users/test/.rvm/rubies/ruby-2.3.0/.irbrc',
  TMPDIR: '/var/folders/d9/rjkk3ch93qlf3c1th1p0gyn40000gp/T/',
  NVM_PATH: '/Users/test/.nvm/versions/node/v6.2.2/lib/node',
  Apple_PubSub_Socket_Render: '/private/tmp/com.apple.launchd.OOTWqHXJWy/Render',
  MY_RUBY_HOME: '/Users/test/.rvm/rubies/ruby-2.3.0',
  rvm_stored_umask: '0022',
  WEBAPP_SERVER_URL: 'http://localhost:9000',
  NVM_DIR: '/Users/test/.nvm',
  USER: 'test',
  _system_type: 'Darwin',
  PARSE_SERVER_DATABASE_URI: 'mongodb://localhost/parse-dev',
  EC2_HOME: '~/ec2',
  rvm_path: '/Users/test/.rvm',
  SSH_AUTH_SOCK: '/private/tmp/com.apple.launchd.B04ZXLN25F/Listeners',
  __CF_USER_TEXT_ENCODING: '0x1F6:0x0:0xF',
  rvm_prefix: '/Users/test',
  PATH: '/Users/test/.nvm/versions/node/v6.2.2/bin:/Library/Frameworks/Python.framework/Versions/3.5/bin:/Users/test/.rvm/gems/ruby-2.3.0/bin:/Users/test/.rvm/gems/ruby-2.3.0@global/bin:/Users/test/.rvm/rubies/ruby-2.3.0/bin:/usr/local/bin:/usr/bin:/bin:/usr/sbin:/sbin:/Users/test/bin:/usr/local:/Users/test/.rvm/bin:/Users/test/.rvm/bin:~/ec2/ec2-api-tools-1.7.5.1/bin:/Users/test/bin:/usr/local:/Users/test/.rvm/bin:/Users/test/.rvm/bin:~/ec2/ec2-api-tools-1.7.5.1/bin',
  rvm_loaded_flag: '1',
  NVM_NODEJS_ORG_MIRROR: 'https://nodejs.org/dist',
  PWD: '/Users/test/GuichiProject',
  JAVA_HOME: '/Library/Java/JavaVirtualMachines/jdk1.8.0_102.jdk/Contents/Home',
  _system_arch: 'x86_64',
  XPC_FLAGS: '0x0',
  _system_version: '10.12',
  XPC_SERVICE_NAME: '0',
  rvm_version: '1.27.0 (latest)',
  SHLVL: '1',
  HOME: '/Users/test',
  LOGNAME: 'test',
  GEM_PATH: '/Users/test/.rvm/gems/ruby-2.3.0:/Users/test/.rvm/gems/ruby-2.3.0@global',
  LC_CTYPE: 'en_AU.UTF-8',
  SERVER_URL: 'http://localhost:8081/parse',
  NVM_BIN: '/Users/test/.nvm/versions/node/v6.2.2/bin',
  LOG_MONGO_URI: 'mongodb://localhost/log',
  NVM_IOJS_ORG_MIRROR: 'https://iojs.org/dist',
  PORT: '9000',
  RUBY_VERSION: 'ruby-2.3.0',
  rvm_user_install_flag: '1',
  _system_name: 'OSX',
  _: '/Users/test/.nvm/versions/node/v6.2.2/bin/node' }

他们完全不同。怎么会发生这种情况?如何读取一些环境变量,例如server.js中的PORT

0 个答案:

没有答案