Check for current Node Version

后端 未结 9 1895
温柔的废话
温柔的废话 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:09

    also instead of writing this whole as suggested by @alsotang

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

    (not saying this is a bad solution).

    you can simply write

    parseFloat(process.versions.node); it is versions (plural) not version

    to get same or (similar) result and is easy to read

提交回复
热议问题