【问题标题】:Equivalent of phpinfo() in Node等价于 Node 中的 phpinfo()
【发布时间】:2019-01-04 03:20:04
【问题描述】:

phpinfoNode 中检查配置设置的等效项是什么?

【问题讨论】:

    标签: node.js environment-variables


    【解决方案1】:

    Here is a link 到提供相同类型信息的包 (nodejs-info)。

    如果您想查看存在哪些环境变量,您也可以console.log 他们喜欢:console.log(process.env);

    【讨论】:

      【解决方案2】:

      它与phpinfo()完全等价,但是您通常会询问 phpinfo 的任何问题都可以通过process 全局变量来回答。 Rastalamm 的回答涉及到这一点,但不仅仅是process.env

      很像 phpinfo,console.log(process) 会告诉你正在运行的节点版本、加载了哪些内部/原生模块(不同于 NPM 模块)以及process.config 下的各种配置设置。

      下面是一个示例,来自我在模拟 Lambda 环境时的 AWS Cloud9 实例:

      2020-04-22 22:32:22.590 process {
        version: 'v12.16.1',
        versions: {
          node: '12.16.1',
          v8: '7.8.279.23-node.31',
          uv: '1.34.0',
          zlib: '1.2.11',
          brotli: '1.0.7',
          ares: '1.15.0',
          modules: '72',
          nghttp2: '1.40.0',
          napi: '5',
          llhttp: '2.0.4',
          http_parser: '2.9.3',
          openssl: '1.1.1d',
          cldr: '36.0',
          icu: '65.1',
          tz: '2019c',
          unicode: '12.1'
        },
        arch: 'x64',
        platform: 'linux',
        release: {
          name: 'node',
          lts: 'Erbium',
          sourceUrl: 'https://nodejs.org/download/release/v12.16.1/node-v12.16.1.tar.gz',
          headersUrl: 'https://nodejs.org/download/release/v12.16.1/node-v12.16.1-headers.tar.gz'
        },
        _rawDebug: [Function: _rawDebug],
        moduleLoadList: [
          'Internal Binding native_module',
          'Internal Binding errors',
          'Internal Binding buffer',
          'NativeModule internal/errors',
          'Internal Binding config',
          'Internal Binding constants',
          'Internal Binding util',
          'Internal Binding types',
          'NativeModule internal/util',
          'NativeModule internal/util/types',
          'NativeModule internal/assert',
          'NativeModule internal/util/inspect',
          'NativeModule events',
          'Internal Binding string_decoder',
          'NativeModule internal/validators',
          'NativeModule internal/buffer',
          'Internal Binding icu',
          'NativeModule buffer',
          'NativeModule internal/process/per_thread',
          'Internal Binding process_methods',
          'Internal Binding credentials',
          'Internal Binding async_wrap',
          'Internal Binding task_queue',
          'NativeModule internal/async_hooks',
          'NativeModule internal/process/promises',
          'NativeModule internal/fixed_queue',
          'NativeModule internal/process/task_queues',
          'Internal Binding trace_events',
          'NativeModule internal/console/constructor',
          'NativeModule internal/console/global',
          'NativeModule internal/util/inspector',
          'Internal Binding inspector',
          'NativeModule internal/querystring',
          'NativeModule internal/constants',
          'NativeModule path',
          'Internal Binding url',
          'NativeModule internal/url',
          'NativeModule internal/encoding',
          'Internal Binding timers',
          'NativeModule internal/linkedlist',
          'NativeModule internal/priority_queue',
          'NativeModule internal/util/debuglog',
          'NativeModule internal/timers',
          'NativeModule timers',
          'NativeModule internal/process/execution',
          'NativeModule internal/process/warning',
          'NativeModule internal/process/signal',
          'Internal Binding options',
          'NativeModule internal/options',
          'NativeModule internal/bootstrap/pre_execution',
          'NativeModule internal/inspector_async_hook',
          'Internal Binding fs',
          'NativeModule internal/fs/utils',
          'Internal Binding fs_dir',
          'NativeModule internal/fs/dir',
          'NativeModule fs',
          'NativeModule internal/idna',
          'NativeModule url',
          'NativeModule internal/modules/cjs/helpers',
          'NativeModule internal/source_map/source_map_cache',
          'Internal Binding contextify',
          'NativeModule vm',
          'NativeModule internal/modules/cjs/loader',
          'NativeModule internal/modules/run_main',
          'Internal Binding module_wrap',
          'NativeModule util',
          'NativeModule internal/assert/assertion_error',
          'NativeModule assert',
          'NativeModule internal/streams/pipeline',
          'NativeModule internal/streams/end-of-stream',
          'NativeModule internal/streams/legacy',
          'NativeModule internal/streams/buffer_list',
          'NativeModule internal/streams/destroy',
          'NativeModule internal/streams/state',
          'NativeModule _stream_readable',
          'NativeModule _stream_writable',
          'NativeModule _stream_duplex',
          'NativeModule _stream_transform',
          'NativeModule _stream_passthrough',
          'NativeModule stream',
          'NativeModule internal/net',
          'Internal Binding uv',
          'Internal Binding stream_wrap',
          'Internal Binding tcp_wrap',
          'Internal Binding pipe_wrap',
          'NativeModule internal/stream_base_commons',
          'NativeModule internal/dtrace',
          'NativeModule net',
          'NativeModule _http_agent',
          'Internal Binding http_parser_llhttp',
          'NativeModule internal/freelist',
          'NativeModule _http_incoming',
          'NativeModule _http_common',
          'Internal Binding performance',
          'NativeModule internal/http',
          'NativeModule _http_outgoing',
          'NativeModule _http_client',
          'NativeModule _http_server',
          'NativeModule http'
        ],
        binding: [Function: binding],
        _linkedBinding: [Function: _linkedBinding],
        _events: [Object: null prototype] {
          newListener: [Function: startListeningIfSignal],
          removeListener: [Function: stopListeningIfSignal],
          warning: [Function: onWarning],
          uncaughtException: [Function],
          unhandledRejection: [Function],
          beforeExit: [Function: invoke]
        },
        _eventsCount: 6,
        _maxListeners: undefined,
        domain: null,
        _exiting: false,
        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,
            gas_version: '2.29',
            host_arch: 'x64',
            icu_data_in: '../../deps/icu/source/data/in/icudt65l.dat',
            icu_endianness: 'l',
            icu_gyp_path: 'tools/icu/icu-generic.gyp',
            icu_path: 'deps/icu',
            icu_small: false,
            icu_ver_major: '65',
            is_debug: 0,
            llvm_version: '0.0',
            napi_build_version: '5',
            node_byteorder: 'little',
            node_debug_lib: false,
            node_enable_d8: false,
            node_install_npm: true,
            node_module_version: 72,
            node_no_browser_globals: false,
            node_prefix: '/var/lang',
            node_release_urlbase: '',
            node_report: true,
            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: false,
            node_use_large_pages: false,
            node_use_large_pages_script_lld: false,
            node_use_node_code_cache: true,
            node_use_node_snapshot: true,
            node_use_openssl: true,
            node_use_v8_platform: true,
            node_with_ltcg: false,
            node_without_node_options: false,
            openssl_fips: '',
            openssl_is_fips: false,
            shlib_suffix: 'so.72',
            target_arch: 'x64',
            v8_enable_gdbjit: 0,
            v8_enable_i18n_support: 1,
            v8_enable_inspector: 1,
            v8_no_strict_aliasing: 1,
            v8_optimized_debug: 1,
            v8_promise_internal_field_count: 1,
            v8_random_seed: 0,
            v8_trace_maps: 0,
            v8_use_siphash: 1,
            v8_use_snapshot: 1,
            want_separate_host_toolset: 0
          }
        },
        dlopen: [Function: dlopen],
        uptime: [Function: uptime],
        _getActiveRequests: [Function: _getActiveRequests],
        _getActiveHandles: [Function: _getActiveHandles],
        reallyExit: [Function: reallyExit],
        _kill: [Function: _kill],
        hrtime: [Function: hrtime] { bigint: [Function: hrtimeBigInt] },
        cpuUsage: [Function: cpuUsage],
        resourceUsage: [Function: resourceUsage],
        memoryUsage: [Function: memoryUsage],
        kill: [Function: kill],
        exit: [Function: exit],
        openStdin: [Function],
        getuid: [Function: getuid],
        geteuid: [Function: geteuid],
        getgid: [Function: getgid],
        getegid: [Function: getegid],
        getgroups: [Function: getgroups],
        allowedNodeEnvironmentFlags: [Getter/Setter],
        assert: [Function: deprecated],
        features: {
          inspector: true,
          debug: false,
          uv: true,
          ipv6: true,
          tls_alpn: true,
          tls_sni: true,
          tls_ocsp: true,
          tls: true,
          cached_builtins: true
        },
        _fatalException: [Function],
        setUncaughtExceptionCaptureCallback: [Function: setUncaughtExceptionCaptureCallback],
        hasUncaughtExceptionCaptureCallback: [Function: hasUncaughtExceptionCaptureCallback],
        emitWarning: [Function: emitWarning],
        nextTick: [Function: nextTick],
        _tickCallback: [Function: runNextTicks],
        _debugProcess: [Function: _debugProcess],
        _debugEnd: [Function: _debugEnd],
        _startProfilerIdleNotifier: [Function: _startProfilerIdleNotifier],
        _stopProfilerIdleNotifier: [Function: _stopProfilerIdleNotifier],
        stdout: [Getter],
        stdin: [Getter],
        stderr: [Getter],
        abort: [Function: abort],
        umask: [Function: wrappedUmask],
        chdir: [Function: wrappedChdir],
        cwd: [Function: wrappedCwd],
        initgroups: [Function: initgroups],
        setgroups: [Function: setgroups],
        setegid: [Function],
        seteuid: [Function],
        setgid: [Function],
        setuid: [Function],
        env: {
          AWS_LAMBDA_FUNCTION_VERSION: '$LATEST',
          HOSTNAME: '164a55144521',
          _LAMBDA_CONTROL_SOCKET: '14',
          AWS_SAM_LOCAL: 'true',
          AWS_SESSION_TOKEN: 'IQoJb3JpZ2luX2VjECYaCXVzLWVhc3QtMSJHMEUCIE0b15xzUs/7OJwC7KgnlcbQBDKw2Yk1rBWF2n+fNd5XAiEAnBq6JH9+yxYZ4b5NNNVcTJeTm9mVVGo8t7Y6i0if7g8q6QIITxACGgw4NzI5NjE4Nzk3OTIiDAhAh1CMtSrXFj+u7CrGAi3M4TF9G1voVlgm7Jr2yDA7aEp21njy1ON0SjMJxVR73lfmVkKkrscdfogbBfeYDUcZQ3jfnhxrY1LW+hPKChuXjE7sHSeaLe4m0DUQ5x8LVh5IPT/gxBkMS6AkrzV+BTybYRGl5JqD8i6ZYpdfEowigBx7dVblO7u5tDqNT+FMfxRqLxRJkJJk6SA9hkD6DGpU1rqSzg2OYlc25L+DN2RGOcKQPEOSn7r1AsqZwUOkRzDd8w0srpldZZQJndWZjNEXkvxaN2NhWELZDY2mMFKrETQti6KvhX2/TCc5k/VEbufJdRLZBKo9g6aqH1X59H68XW/cP8Z8sMx2Rkpfan0ivL2SIecP5TdYUte/nA67H6y5EQ+daX4nRroQofwX0TEcRcpcV8S7CWYSKs84ASr0XTBQMfATXJW/uOYVd8pjBWh37K73MIXZgvUFOs4Cb+85Ww32Hf68YGC0Anw7r9mKl+e6+8X6XW68bX5Py9+7ZcCF+C0GU53ENakeXOHdkA70h3B+4I1kuS8vL9f0xTjoY8lXM7oRdLxpqHjFiHHjx2TViu0mpxZ3VP8lCjgoWBhLmGC8KHHPztLlPj58HuWHb519eZATd6o6NG+n14wWmsCAf+zboZBJZe5eENK7HheoRKkniUlj+1QBS3ASwJIKwgLanpi+LoWH5r0EiQZn+fCczRnIZjSz0P/roopWQEepAWxXm8R5gJAlmkDNaGsFWWLdCJyBfLWZvDS8GUujicZhPQ3ELa5zCiwIAwi/oCDD8tIkv7L/liRwwZfAQsG8ZYBWMw6geSW1Gf9k6PjCZIR+CMLQ5NPfWRDcZFrmUZyglroUdYzykxwJ2+Jx8N9QHDWhhPlEMhMoJsiEoByJveXuw55oO23ZVCBPwQ==',
          AWS_LAMBDA_FUNCTION_TIMEOUT: '15',
          AWS_LAMBDA_LOG_GROUP_NAME: '/aws/lambda/test',
          LAMBDA_TASK_ROOT: '/var/task',
          LD_LIBRARY_PATH: '/var/lang/lib:/lib64:/usr/lib64:/var/runtime:/var/runtime/lib:/var/task:/var/task/lib:/opt/lib',
          AWS_LAMBDA_RUNTIME_API: '127.0.0.1:9001',
          AWS_LAMBDA_LOG_STREAM_NAME: '2020/04/22/[$LATEST]8ac4142c629e7e08931e5a0eaff80123',
          _LAMBDA_SHARED_MEM_FD: '11',
          AWS_EXECUTION_ENV: 'AWS_Lambda_nodejs12.x',
          _LAMBDA_RUNTIME_LOAD_TIME: '1530232235231',
          AWS_LAMBDA_FUNCTION_NAME: 'test',
          AWS_XRAY_DAEMON_ADDRESS: '169.254.79.2:2000',
          PATH: '/var/lang/bin:/usr/local/bin:/usr/bin/:/bin:/opt/bin',
          _LAMBDA_LOG_FD: '9',
          AWS_DEFAULT_REGION: 'us-east-1',
          PWD: '/var/task',
          AWS_SECRET_ACCESS_KEY: 'YNF6WsPQ2sXHi3CNi5a3TDuL2LnGZZdGLHv6x7J1',
          LAMBDA_RUNTIME_DIR: '/var/runtime',
          LANG: 'en_US.UTF-8',
          NODE_PATH: '/opt/nodejs/node12/node_modules:/opt/nodejs/node_modules:/var/runtime/node_modules:/var/runtime:/var/task',
          TZ: ':UTC',
          AWS_REGION: 'us-east-1',
          AWS_LAMBDA_FUNCTION_HANDLER: 'RunSync/index.handler',
          AWS_ACCESS_KEY_ID: 'ASIA4WQEVF3YKL2RO2HZ',
          SHLVL: '0',
          HOME: '/home/sbx_user1051',
          _AWS_XRAY_DAEMON_ADDRESS: '169.254.79.2',
          _AWS_XRAY_DAEMON_PORT: '2000',
          _X_AMZN_TRACE_ID: 'Root=1-dc99d00f-c079a84d433534434534ef0d;Parent=91ed514f1e5c03b2;Sampled=1',
          _LAMBDA_SB_ID: '7',
          AWS_XRAY_CONTEXT_MISSING: 'LOG_ERROR',
          _LAMBDA_CONSOLE_SOCKET: '16',
          _HANDLER: 'RunSync/index.handler',
          AWS_LAMBDA_FUNCTION_MEMORY_SIZE: '256',
          AWS_LAMBDA_EVENT_BODY: '{}'
        },
        title: '/var/lang/bin/node',
        argv: [ '/var/lang/bin/node', '/var/runtime/index.js' ],
        execArgv: [
          '--expose-gc',
          '--max-http-header-size',
          '81920',
          '--max-semi-space-size=12',
          '--max-old-space-size=231'
        ],
        pid: 12,
        ppid: 1,
        execPath: '/var/lang/bin/node',
        debugPort: 9229,
        argv0: '/var/lang/bin/node',
        _preload_modules: [],
        mainModule: Module {
          id: '.',
          path: '/var/runtime',
          exports: {},
          parent: null,
          filename: '/var/runtime/index.js',
          loaded: true,
          children: [ [Module], [Module], [Module], [Module], [Module], [Module] ],
          paths: [
            '/var/runtime/node_modules',
            '/var/node_modules',
            '/node_modules'
          ]
        },
        [Symbol(kCapture)]: false
      }
      

      【讨论】:

        猜你喜欢
        • 2011-02-04
        • 2021-05-24
        • 2015-04-12
        • 2013-12-16
        • 2022-06-11
        • 2021-12-21
        • 1970-01-01
        • 2011-04-25
        相关资源
        最近更新 更多