找不到“cypress”.ts 的类型定义文件

Del*_*mke 14 xpath cypress cypress-cucumber-preprocessor

当尝试 npm install -D cypress-xpath 到已安装 cypress-cucumber-preprocessor 的 Cypress 项目 [require('cypress-xpath') 添加到我的 cypress/support/index.js] 时,我收到以下错误插件 > index.js 文件用于"/// <reference types="cypress" />"?

找不到“cypress”的类型定义文件.ts(2688)

添加到插件 > index.js 文件

const cucumber = require('cypress-cucumber-preprocessor').default
module.exports = (on, config) => {
on('file:preprocessor', cucumber())
}
Run Code Online (Sandbox Code Playgroud)

package.json 文件

"devdependencies": {
    "cypress": "^8.3.1",
    "cypress-cucumber-preprocessor": "^4.2.0"
  },
  "Dependencies": {
    "cypress-xpath": "^1.6.2"
  }
Run Code Online (Sandbox Code Playgroud)

支持>index.js文件

require('cypress-xpath')
Run Code Online (Sandbox Code Playgroud)

运行时:

npx cypress open
Run Code Online (Sandbox Code Playgroud)

插件文件丢失或无效。

您的pluginsFile设置为C:\Users\Delwin\VSCode\Cypress\Cucumber1\cypress\plugins\index.js,但文件丢失,包含语法错误,或者在需要时抛出错误。pluginsFile 必须是 .js、.ts 或 .coffee 文件。

或者您可能已重命名您的pluginsFile 的扩展名。如果是这种情况,请重新启动测试运行程序。

请修复此问题,或者如果您的项目不需要插件文件,请将pluginsFile 设置为 false。

错误:找不到模块“cypress-cucumber-preprocessor”

Aks*_*ain 10

通过安装最新的柏树类型解决了我的问题

npm i -D @types/cypress@latest


小智 0

我遇到了同样的错误,我通过安装 cypress 修复了, https://docs.cypress.io/guides/getting-started/installing-cypress