无法运行任何Gulp命令

0vvn1miw  于 9个月前  发布在  Gulp
关注(0)|答案(5)|浏览(168)

我对NodeJS比较陌生,正在学习使用Sharepoint Framework进行开发。它工作得很好,突然开始抛出错误。
我的NodeJS版本是:V10.13.0
我的gulp版本是:CLI - 2.0.1Local - 3.9.1
当我尝试使用gulp servegulp bundle时,我得到以下错误:
错误:您的开发环境运行的是NodeJS v10.13.0,不符合运行此工具的要求。此工具需要NodeJS版本匹配>=8.9.4 <9.0.0.......
有人能帮我解决这个问题吗?
非常感谢,

nlejzf6q

nlejzf6q1#

我设法解决了这个问题。
对于那些可能从中受益的人:
在我将@microsoft/generator-sharepoint升级到最新版本后发生了这个错误。一旦卸载了1.7.0版本并安装了1.6.0,一切都像预期的那样顺利地开始工作了。
谢谢

dz6r00yl

dz6r00yl2#

另一个解决方案是安装Node版本管理器,然后您可以使用它管理node.js的版本。
nvm-windows
安装.exe文件,然后管理node.js版本。
节点版本管理器命令:

Usage:

  nvm install <version>        : Install node.js specific version
  nvm list                     : List the node.js installations.       
  nvm use [version]            : Switch to specific node.js version
  .....
  ...

字符串

cfh9epnr

cfh9epnr3#

这是另一个可能的解决方案:
我也有同样的问题,除了对我来说的解决方案是“阅读”:)对于其他面临同样问题的人,请注意微软网站上的以下内容:
请注意,SharePoint Framework开发目前不支持9.x或10.x版本。
这意味着我不得不将Nodejs版本降级到8.13,因为9.0以上的任何版本都不能与SPFX(目前)一起使用。
此页摘录:https://learn.microsoft.com/en-us/sharepoint/dev/spfx/set-up-your-development-environment

piv4azn7

piv4azn74#

SharePoint Framework当前支持的NodeJS LTS版本是Node.js v8.x和Node.js v10.x。请注意,SharePoint Framework开发当前不支持9.x、11.x或12.x版本。

sulc1iza

sulc1iza5#

在Windows上,我遇到了类似的错误。

Error: Your dev environment is running NodeJS version v18.9.1 which does not meet the requirements for running this tool. This tool requires a version of NodeJS that matches >=12.13.0 <13.0.0 || >=14.15.0 <15.0.0 || >=16.13.0 <17.0.0 || >=18.17.1 <19.0.0
    at SPWebBuildRig.initialize (C:\Users\evaughan\OneDrive - PhishingBox LLC\Documents\PBox General\Scripts\Sharepoint\node_modules\@microsoft\sp-build-web\lib\SPBuildRig.js:50:19)
    at Object.initialize (C:\Users\evaughan\OneDrive - PhishingBox LLC\Documents\PBox General\Scripts\Sharepoint\node_modules\@microsoft\sp-build-web\lib\index.js:35:17)
    at Object.<anonymous> (C:\Users\evaughan\OneDrive - PhishingBox LLC\Documents\PBox General\Scripts\Sharepoint\gulpfile.js:16:7)
    at Module._compile (node:internal/modules/cjs/loader:1119:14)
    at Module._extensions..js (node:internal/modules/cjs/loader:1173:10)
    at Module.load (node:internal/modules/cjs/loader:997:32)
    at Module._load (node:internal/modules/cjs/loader:838:12)
    at Module.require (node:internal/modules/cjs/loader:1021:19)
    at require (node:internal/modules/cjs/helpers:103:18)
    at requireOrImport (C:\Users\evaughan\AppData\Roaming\npm\node_modules\gulp-cli\lib\shared\require-or-import.js:19:11)

字符串
为了解决这个问题,我安装了NodeJS,下载并从这里运行了MSI 18.17.1:https://nodejs.org/dist/v18.17.1/

相关问题