gulp version.match->无法读取属性“ match”

时间:2018-06-29 09:26:40

标签: javascript html css sass gulp

好吧,所以我对gulp和sass还是陌生的,我正努力使它起作用。我正确安装了所有内容,但出现了这个愚蠢的错误。有解决方案吗?

PS C:\Users\Bojan Kolano\Desktop\Fax i projekti\Portfolio\Product Landing 
Page Project> gulp sass:watch
C:\Users\Bojan Kolano\AppData\Roaming\npm\node_modules\gulp- 
cli\node_modules\sver-compat\sver.js:19
var semver = version.match(semverRegEx);
                   ^

TypeError: Cannot read property 'match' of undefined
  at new Semver (C:\Users\Bojan Kolano\AppData\Roaming\npm\node_modules\gulp- cli\node_modules\sver-compat\sver.js:19:24)
  at Function.match (C:\Users\Bojan Kolano\AppData\Roaming\npm\node_modules\gulp-cli\node_modules\sver-compat\sver.js:374:15)
  at matches (C:\Users\Bojan Kolano\AppData\Roaming\npm\node_modules\gulp-cli\node_modules\semver-greatest-satisfied-range\index.js:9:24)
  at Array.filter (<anonymous>)
  at findRange (C:\Users\Bojan Kolano\AppData\Roaming\npm\node_modules\gulp-cli\node_modules\semver-greatest-satisfied-range\index.js:12:28)
  at Liftoff.handleArguments (C:\Users\Bojan Kolano\AppData\Roaming\npm\node_modules\gulp-cli\index.js:166:15)
  at Liftoff.execute (C:\Users\Bojan Kolano\AppData\Roaming\npm\node_modules\gulp-cli\node_modules\liftoff\index.js:203:12)
  at module.exports (C:\Users\Bojan Kolano\AppData\Roaming\npm\node_modules\gulp-cli\node_modules\flagged-respawn\index.js:51:3)
  at Liftoff.<anonymous> (C:\Users\Bojan Kolano\AppData\Roaming\npm\node_modules\gulp-cli\node_modules\liftoff\index.js:195:5)
  at C:\Users\Bojan Kolano\AppData\Roaming\npm\node_modules\gulp-cli\node_modules\liftoff\index.js:165:9
  PS C:\Users\Bojan Kolano\Desktop\Fax i projekti\Portfolio\Product Landing 
  Page Project>

3 个答案:

答案 0 :(得分:3)

删除package-lock.json和node_modules文件夹,然后重新安装所有模块!应该可以:)

答案 1 :(得分:0)

发生这种情况的原因有很多。对我来说,这是因为我已经在全球范围内安装了gulp,但没有 not 将其添加到我的项目中。一旦我安装了gulp(npm install gulp),任务就成功运行了。它本来应该很明显,但是我第一次错过了它。

答案 2 :(得分:0)

删除 package-lock.jsonnode_modules 文件夹并重新安装对我不起作用。但似乎我没有在全球范围内安装 Gulp。所以我所做的,我只是像这样在本地安装它:npm install gulp --save-dev,现在它可以工作了。