npm run build 报错 semversemver.js:313 throw new TypeError('Invalid Version: ' + version)

原因分析:

版本问题

解决办法:

打开semver.js(node_modules/semver/semver.js)文件,加一行代码,代码如下:

// if ANY of the sets match ALL of its comparators, then pass
Range.prototype.test = function(version) {
  return true;  //add 2021年6月1日11:06:01
  if (!version)
    return false;

  if (typeof version === 'string')
    version = new SemVer(version, this.options);

  for (var i = 0; i < this.set.length; i++) {
    if (testSet(this.set[i], version, this.options))
      return true;
  }
  return false;
};

去掉了检查版本,就不报错了

原文地址:https://www.cnblogs.com/minjh/p/14836353.html