Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

NODE_ENV #13

Open
xgqfrms-GitHub opened this issue Jun 25, 2017 · 6 comments
Open

NODE_ENV #13

xgqfrms-GitHub opened this issue Jun 25, 2017 · 6 comments
Labels
bash shell chmod bash shell chmod cross-env cross-env enhancement ImageMagick ImageMagick NODE_ENV NODE_ENV Node.js & npm scripts Node.js & npm scripts

Comments

@xgqfrms-GitHub
Copy link
Owner

NODE_ENV

node_env

https://stackoverflow.com/questions/16978256/what-is-node-env-in-express

https://stackoverflow.com/a/16979503/5934465

https://nodejs.org/dist/latest-v6.x/docs/api/

https://nodejs.org/en/docs/es6/

linux & mac:

$ export NODE_ENV=production

windows:

$ set NODE_ENV=production
@xgqfrms-GitHub
Copy link
Owner Author

xgqfrms-GitHub commented Jun 25, 2017

process.env

https://nodejs.org/dist/latest-v6.x/docs/api/process.html#process_process_env

{
  TERM: 'xterm-256color',
  SHELL: '/usr/local/bin/bash',
  USER: 'maciej',
  PATH: '~/.bin/:/usr/bin:/bin:/usr/sbin:/sbin:/usr/local/bin',
  PWD: '/Users/maciej',
  EDITOR: 'vim',
  SHLVL: '1',
  HOME: '/Users/maciej',
  LOGNAME: 'maciej',
  _: '/usr/local/bin/node'
}

可以修改此对象,但这些修改不会反映在Node.js进程之外。
换句话说,以下示例将不起作用:

$ node -e 'process.env.foo = "bar"' && echo $foo

以下将会:

process.env.foo = 'bar';
console.log(process.env.foo);

在process.env上分配属性会将值隐式转换为字符串。

new version bug

v10.15.3

https://nodejs.org/api/process.html#process_process_env

image

@xgqfrms-GitHub
Copy link
Owner Author

xgqfrms-GitHub commented Jun 25, 2017

ECMAScript 2015 (ES6) and beyond

https://nodejs.org/en/docs/es6/

$ node --v8-options | grep "in progress"

$ node -p process.versions.v8
$ node -p process

$ node -p process.env
D:\SVN\GFT\web\App>node -p process
process {
  title: '  - node  -p process',
  version: 'v10.15.3',
  versions:
   { http_parser: '2.8.0',
     node: '10.15.3',
     v8: '6.8.275.32-node.51',
     uv: '1.23.2',
     zlib: '1.2.11',
     ares: '1.15.0',
     modules: '64',
     nghttp2: '1.34.0',
     napi: '3',
     openssl: '1.1.0j',
     icu: '62.1',
     unicode: '11.0',
     cldr: '33.1',
     tz: '2018e' },
  arch: 'x64',
  platform: 'win32',
  release:
   { name: 'node',
     lts: 'Dubnium',
     sourceUrl:
      'https://nodejs.org/download/release/v10.15.3/node-v10.15.3.tar.gz',
     headersUrl:
      'https://nodejs.org/download/release/v10.15.3/node-v10.15.3-headers.tar.gz',
     libUrl:
      'https://nodejs.org/download/release/v10.15.3/win-x64/node.lib' },
  argv: [ 'H:\\Program Files\\nodejs\\node.exe' ],
  execArgv: [ '-p', 'process' ],
  env:
   { ALLUSERSPROFILE: 'C:\\ProgramData',
     ANDROID_HOME: 'H:\\Android-SDK',
     APPDATA: 'C:\\Users\\xgqfrms\\AppData\\Roaming',
     CommonProgramFiles: 'C:\\Program Files\\Common Files',
     'CommonProgramFiles(x86)': 'C:\\Program Files (x86)\\Common Files',
     CommonProgramW6432: 'C:\\Program Files\\Common Files',
     COMPUTERNAME: 'NB2-xgqfrms',
     ComSpec: 'C:\\WINDOWS\\system32\\cmd.exe',
     DriverData: 'C:\\Windows\\System32\\Drivers\\DriverData',
     FPS_BROWSER_APP_PROFILE_STRING: 'Internet Explorer',
     FPS_BROWSER_USER_PROFILE_STRING: 'Default',
     HOMEDRIVE: 'C:',
     HOMEPATH: '\\Users\\xgqfrms',
     JAVA_HOME: 'H:\\JDK-12',
     LOCALAPPDATA: 'C:\\Users\\xgqfrms\\AppData\\Local',
     LOGONSERVER: '\\\\FILE',
     NUMBER_OF_PROCESSORS: '8',
     OneDrive: 'C:\\Users\\xgqfrms\\OneDrive',
     OS: 'Windows_NT',
     Path:
      'H:\\Program Files\\ImageMagick-7.0.8-Q16;H:\\Python27\\;H:\\Python27\\Scripts;C:\\WINDOWS\\system32;C:\\WINDOWS;C:\\WINDOWS\\System32\\Wbem;C:\\WINDOWS\\System32\\WindowsPowerShell\\v1.0\\;H:\\Program Files\\nodejs\\;H:\\Program Files (x86)\\Yarn\\bin\\;H:\\Program Files\\TortoiseSVN\\bin;H:\\Program Files\\Git\\cmd;H:\\JDK-12\\bin;;C:\\WINDOWS\\System32\\OpenSSH\\;C:\\Users\\xgqfrms\\AppData\\Local\\Microsoft\\WindowsApps;C:\\Users\\xgqfrms\\AppData\\Roaming\\npm;C:\\Users\\xgqfrms\\AppData\\Local\\Yarn\\bin;H:\\Program Files\\Microsoft VS Code\\bin;C:\\Users\\xgqfrms\\AppData\\Local\\GitHubDesktop\\bin;C:\\Users\\xgqfrms\\AppData\\Local\\Microsoft\\WindowsApps;H:\\Android-SDK\\platform-tools;',
     PATHEXT: '.COM;.EXE;.BAT;.CMD;.VBS;.VBE;.JS;.JSE;.WSF;.WSH;.MSC',
     'process.env.TEST ': ' 1T ',
     PROCESSOR_ARCHITECTURE: 'AMD64',
     PROCESSOR_IDENTIFIER: 'Intel64 Family 6 Model 142 Stepping 10, GenuineIntel',
     PROCESSOR_LEVEL: '6',
     PROCESSOR_REVISION: '8e0a',
     ProgramData: 'C:\\ProgramData',
     ProgramFiles: 'C:\\Program Files',
     'ProgramFiles(x86)': 'C:\\Program Files (x86)',
     ProgramW6432: 'C:\\Program Files',
     PROMPT: '$P$G',
     PSModulePath:
      'C:\\Program Files\\WindowsPowerShell\\Modules;C:\\WINDOWS\\system32\\WindowsPowerShell\\v1.0\\Modules',
     PUBLIC: 'C:\\Users\\Public',
     SESSIONNAME: 'Console',
     SystemDrive: 'C:',
     SystemRoot: 'C:\\WINDOWS',
     TEMP: 'C:\\Users\\xgqfrms\\AppData\\Local\\Temp',
     TMP: 'C:\\Users\\xgqfrms\\AppData\\Local\\Temp',
     USERDNSDOMAIN: 'XYZDATA.COM',
     USERDOMAIN: 'XYZDATA',
     USERDOMAIN_ROAMINGPROFILE: 'XYZDATA',
     USERNAME: 'xgqfrms',
     USERPROFILE: 'C:\\Users\\xgqfrms',
     windir: 'C:\\WINDOWS',
     TERM_PROGRAM: 'vscode',
     TERM_PROGRAM_VERSION: '1.33.1',
     LANG: 'en_US.UTF-8' },
  pid: 22112,
  features:
   { debug: false,
     uv: true,
     ipv6: true,
     tls_alpn: true,
     tls_sni: true,
     tls_ocsp: true,
     tls: true },
  ppid: 9904,
  _eval: 'process',
  _print_eval: true,
  execPath: 'H:\\Program Files\\nodejs\\node.exe',
  debugPort: 9229,
  _debugProcess: [Function: _debugProcess],
  _debugEnd: [Function: _debugEnd],
  _startProfilerIdleNotifier: [Function: _startProfilerIdleNotifier],
  _stopProfilerIdleNotifier: [Function: _stopProfilerIdleNotifier],
  abort: [Function: abort],
  chdir: [Function: chdir],
  umask: [Function: umask],
  _getActiveRequests: [Function: _getActiveRequests],
  _getActiveHandles: [Function: _getActiveHandles],
  _kill: [Function: _kill],
  cwd: [Function: cwd],
  dlopen: [Function: dlopen],
  reallyExit: [Function: reallyExit],
  uptime: [Function: uptime],
  _rawDebug: [Function],
  moduleLoadList:
   [ 'Internal Binding module_wrap',
     'Binding contextify',
     'Internal Binding worker',
     'NativeModule events',
     'NativeModule internal/async_hooks',
     'NativeModule internal/errors',
     'Binding uv',
     'Binding buffer',
     'Binding async_wrap',
     'Internal Binding async_wrap',
     'Binding config',
     'Binding icu',
     'NativeModule util',
     'NativeModule internal/util/inspect',
     'Binding util',
     'NativeModule internal/util',
     'Binding constants',
     'Internal Binding types',
     'NativeModule internal/util/types',
     'NativeModule internal/validators',
     'NativeModule internal/encoding',
     'Internal Binding icu',
     'NativeModule buffer',
     'NativeModule internal/buffer',
     'NativeModule internal/process/per_thread',
     'NativeModule internal/process/main_thread_only',
     'NativeModule internal/process/stdio',
     'NativeModule assert',
     'NativeModule internal/assert',
     'NativeModule fs',
     'NativeModule path',
     'NativeModule internal/constants',
     'Binding fs',
     'NativeModule internal/fs/streams',
     'NativeModule internal/fs/utils',
     'NativeModule stream',
     'NativeModule internal/streams/pipeline',
     'NativeModule internal/streams/end-of-stream',
     'NativeModule internal/streams/legacy',
     'NativeModule _stream_readable',
     'NativeModule internal/streams/buffer_list',
     'NativeModule internal/streams/destroy',
     'NativeModule internal/streams/state',
     'NativeModule _stream_writable',
     'NativeModule _stream_duplex',
     'NativeModule _stream_transform',
     'NativeModule _stream_passthrough',
     'NativeModule internal/url',
     'NativeModule internal/querystring',
     'Binding url',
     'NativeModule internal/process/warning',
     'NativeModule internal/process/next_tick',
     'NativeModule internal/process/promises',
     'Internal Binding util',
     'NativeModule internal/fixed_queue',
     'Binding performance',
     'Binding trace_events',
     'NativeModule internal/inspector_async_hook',
     'Binding inspector',
     'NativeModule internal/options',
     'Internal Binding options',
     'NativeModule timers',
     'Binding timer_wrap',
     'NativeModule internal/linkedlist',
     'NativeModule internal/timers',
     'NativeModule console',
     'Binding tty_wrap',
     'Internal Binding tty_wrap',
     'NativeModule tty',
     'NativeModule net',
     'NativeModule internal/net',
     'Binding stream_wrap',
     'Binding tcp_wrap',
     'Binding pipe_wrap',
     'NativeModule internal/stream_base_commons',
     'Internal Binding stream_wrap',
     'Internal Binding uv',
     'NativeModule internal/tty',
     'Binding signal_wrap',
     'NativeModule internal/modules/cjs/loader',
     'NativeModule vm',
     'NativeModule url',
     'NativeModule internal/safe_globals',
     'NativeModule internal/modules/cjs/helpers',
     'NativeModule os',
     'Binding os' ],
  binding: [Function: binding],
  _linkedBinding: [Function: _linkedBinding],
  _events:
   [Object: null prototype] {
     newListener: [Function],
     removeListener: [Function],
     warning: [Function],
     SIGWINCH: [ [Function], [Function] ] },
  _eventsCount: 4,
  _maxListeners: undefined,
  _fatalException: [Function],
  domain: null,
  _exiting: false,
  assert: [Function: deprecated],
  config:
   { target_defaults:
      { cflags: [],
        default_configuration: 'Release',
        defines: [],
        include_dirs: [],
        libraries: [] },
     variables:
      { asan: 0,
        build_v8_with_gn: false,
        coverage: false,
        debug_nghttp2: false,
        enable_lto: false,
        enable_pgo_generate: false,
        enable_pgo_use: false,
        force_dynamic_crt: 0,
        host_arch: 'x64',
        icu_data_in: '..\\..\\deps/icu-small\\source/data/in\\icudt62l.dat',
        icu_endianness: 'l',
        icu_gyp_path: 'tools/icu/icu-generic.gyp',
        icu_locales: 'en,root',
        icu_path: 'deps/icu-small',
        icu_small: true,
        icu_ver_major: '62',
        nasm_version: '2.14',
        node_byteorder: 'little',
        node_debug_lib: false,
        node_enable_d8: false,
        node_enable_v8_vtunejit: false,
        node_install_npm: true,
        node_module_version: 64,
        node_no_browser_globals: false,
        node_prefix: '/usr/local',
        node_release_urlbase: 'https://nodejs.org/download/release/',
        node_shared: false,
        node_shared_cares: false,
        node_shared_http_parser: false,
        node_shared_libuv: false,
        node_shared_nghttp2: false,
        node_shared_openssl: false,
        node_shared_zlib: false,
        node_tag: '',
        node_target_type: 'executable',
        node_use_bundled_v8: true,
        node_use_dtrace: false,
        node_use_etw: true,
        node_use_large_pages: false,
        node_use_openssl: true,
        node_use_pch: false,
        node_use_perfctr: true,
        node_use_v8_platform: true,
        node_with_ltcg: true,
        node_without_node_options: false,
        openssl_fips: '',
        openssl_no_asm: 0,
        shlib_suffix: 'so.64',
        target_arch: 'x64',
        v8_enable_gdbjit: 0,
        v8_enable_i18n_support: 1,
        v8_enable_inspector: 1,
        v8_no_strict_aliasing: 1,
        v8_optimized_debug: 0,
        v8_promise_internal_field_count: 1,
        v8_random_seed: 0,
        v8_trace_maps: 0,
        v8_typed_array_max_size_in_heap: 0,
        v8_use_snapshot: true,
        want_separate_host_toolset: 0 } },
  setUncaughtExceptionCaptureCallback: [Function],
  hasUncaughtExceptionCaptureCallback: [Function],
  emitWarning: [Function],
  nextTick: [Function: nextTick],
  _tickCallback: [Function: _tickCallback],
  stdout: [Getter],
  stderr: [Getter],
  stdin: [Getter],
  openStdin: [Function],
  hrtime: { [Function: hrtime] bigint: [Function] },
  cpuUsage: [Function: cpuUsage],
  memoryUsage: [Function: memoryUsage],
  exit: [Function],
  kill: [Function],
  argv0: 'node',
  allowedNodeEnvironmentFlags: [Getter/Setter] }

D:\SVN\GFT\web\App>

@xgqfrms-GitHub
Copy link
Owner Author

npm scripts

"scripts": {
    "test": "webpack",
    "start": "webpack-dev-server --env development",
    "build": "webpack --env production"
}


"scripts": {
    "test": "webpack",
    "start": "webpack-dev-server --env -d",
    "build": "webpack --env -p"
}




// process.env.NODE_ENV="production"

// webpack -h
# npm run [commads name]


$ npm run dev

$ npm run prop

process.env.NODE_ENV

# into node

$ node

$ > process.env

$ > process.env.NODE_ENV

# exit node

$ > .exit

# Ctrl + C, Ctrl + C

node-cli-tools

https://github.com/xgqfrms-GitHub/Node-CLI-Tools/

NODE_ENV

NODE_ENV, Node-CLI-Tools

#13

linux & mac: export NODE_ENV=production

windows: set NODE_ENV=production

Repository owner locked and limited conversation to collaborators May 7, 2019
@xgqfrms xgqfrms added bash shell chmod bash shell chmod NODE_ENV NODE_ENV labels May 7, 2019
@xgqfrms
Copy link
Collaborator

xgqfrms commented Jun 30, 2021

Windows/PC set node.js NODE_ENV

$ set NODE_ENV=prod
      

Mac/Linux set node.js NODE_ENV

$ export NODE_ENV=prod

跨平台

$ cross-env NODE_ENV=prod

作者:xgqfrms
链接:https://www.cnblogs.com/xgqfrms/p/13501449.html
来源:https://www.cnblogs.com
著作权归作者所有。商业转载请联系作者获得授权,非商业转载请注明出处。
©xgqfrms 2012-2021
www.cnblogs.com 发布文章使用:只允许注册用户才可以访问!
原创文章,版权所有©️xgqfrms, 禁止转载 🈲️,侵权必究⚠️

@xgqfrms xgqfrms added cross-env cross-env Node.js & npm scripts Node.js & npm scripts labels Jun 30, 2021
@xgqfrms xgqfrms added the ImageMagick ImageMagick label Mar 29, 2023
@xgqfrms
Copy link
Collaborator

xgqfrms commented Mar 29, 2023

ImageMagick

Path:
      'H:\\Program Files\\ImageMagick-7.0.8-Q16;H:\\Python27\\;H:\\Python27\\Scripts;C:\\WINDOWS\\system32;C:\\WINDOWS;C:\\WINDOWS\\System32\\Wbem;C:\\WINDOWS\\System32\\WindowsPowerShell\\v1.0\\;H:\\Program Files\\nodejs\\;H:\\Program Files (x86)\\Yarn\\bin\\;H:\\Program Files\\TortoiseSVN\\bin;H:\\Program Files\\Git\\cmd;H:\\JDK-12\\bin;;C:\\WINDOWS\\System32\\OpenSSH\\;C:\\Users\\xgqfrms\\AppData\\Local\\Microsoft\\WindowsApps;C:\\Users\\xgqfrms\\AppData\\Roaming\\npm;C:\\Users\\xgqfrms\\AppData\\Local\\Yarn\\bin;H:\\Program Files\\Microsoft VS Code\\bin;C:\\Users\\xgqfrms\\AppData\\Local\\GitHubDesktop\\bin;C:\\Users\\xgqfrms\\AppData\\Local\\Microsoft\\WindowsApps;H:\\Android-SDK\\platform-tools;',
     PATHEXT: '.COM;.EXE;.BAT;.CMD;.VBS;.VBE;.JS;.JSE;.WSF;.WSH;.MSC',

https://imagemagick.org/

https://github.com/ImageMagick/ImageMagick

https://www.cnblogs.com/xgqfrms/p/17268733.html#5162737

@xgqfrms
Copy link
Collaborator

xgqfrms commented Mar 29, 2023

Sign up for free to subscribe to this conversation on GitHub. Already have an account? Sign in.
Labels
bash shell chmod bash shell chmod cross-env cross-env enhancement ImageMagick ImageMagick NODE_ENV NODE_ENV Node.js & npm scripts Node.js & npm scripts
Projects
None yet
Development

No branches or pull requests

2 participants