Check for current Node Version

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

    Use semver to compare process.version:

    const semver = require('semver');
    
    if (semver.gte(process.version, '0.12.18')) {
      ...
    }
    

提交回复
热议问题