Check for current Node Version

后端 未结 9 1864
温柔的废话
温柔的废话 2021-01-31 06:48

I need to programmatically access the current node version running in a library I am writing. Can\'t seem to find this in the docs.

相关标签:
9条回答
  • 2021-01-31 07:28

    Try to look at process.version property.

    0 讨论(0)
  • 2021-01-31 07:28

    process.version.match(/^v(\d+\.\d+)/)[1]

    if process.version is 'v0.11.5', then get 0.11 .

    0 讨论(0)
  • 2021-01-31 07:29

    If you access node js running environments, there are 2 main entries: (one simeple, one detail)

    • process.version will give you:

    'v10.16.0'

    • process.versions will give you:
    { http_parser: '2.8.0',
      node: '10.16.0',
      v8: '6.8.275.32-node.52',
      uv: '1.28.0',
      zlib: '1.2.11',
      brotli: '1.0.7',
      ares: '1.15.0',
      modules: '64',
      nghttp2: '1.34.0',
      napi: '4',
      openssl: '1.1.1b',
      icu: '64.2',
      unicode: '12.1',
      cldr: '35.1',
      tz: '2019a' }
    
    0 讨论(0)
提交回复
热议问题