You need to enable JavaScript to run this app.
优惠活动
大模型
产品
解决方案
定价
更多

运行Cucumber测试报from参数类型错误ERR_INVALID_ARG_TYPE如何解决?

问题根因

项目依赖同时安装了两个不兼容的Cucumber版本:生产依赖里的旧版cucumber@7.1.0,以及开发依赖里的新版预览版@cucumber/cucumber@8.0.0-rc.1,版本冲突导致Cucumber内部处理代码路径时参数传入异常,触发类型报错。

修复步骤

  • 卸载冲突的旧版本Cucumber包
npm uninstall cucumber
  • 检查报错指向的/features/support/hooks.js第45行代码,确认所有Cucumber相关的API导入都统一使用@cucumber/cucumber,没有引用旧版cucumber包的逻辑
  • 清理本地依赖缓存后重新安装依赖
rm -rf node_modules package-lock.json
npm install
  • 若上述操作后仍报错,将@cucumber/cucumber降级到正式稳定版,避免预览版的未修复缺陷
npm install @cucumber/cucumber@7.1.0 --save-dev

内容的提问来源于stack exchange,提问作者user11918356

相关产品推荐
方舟 Agent Plan

超全模态模型 × Harness 升级,最新支持 Deepseek-V4.1-Flash、GLM-5.3 系列、Doubao-Seedream-5.0-pro、Kimi-K3 (部分), 限时 9.9 元起

最近更新时间:2026.09.26 22:06:00