Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

Cannot find type definition file for 'cypress'.ts

When trying to npm install -D cypress-xpath into a Cypress project [require('cypress-xpath') added to my cypress/support/index.js] with the cypress-cucumber-preprocessor already installed I am getting the below Error in the plugins > index.js file for "/// <reference types="cypress" />"?

Cannot find type definition file for 'cypress'.ts(2688)

Added to plugins > index.js file

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

package.json file

"devdependencies": {
    "cypress": "^8.3.1",
    "cypress-cucumber-preprocessor": "^4.2.0"
  },
  "Dependencies": {
    "cypress-xpath": "^1.6.2"
  }

support > index.js file

require('cypress-xpath')

When running:

npx cypress open

The plugins file is missing or invalid.

Your pluginsFile is set to C:\Users\Delwin\VSCode\Cypress\Cucumber1\cypress\plugins\index.js, but either the file is missing, it contains a syntax error, or threw an error when required. The pluginsFile must be a .js, .ts, or .coffee file.

Or you might have renamed the extension of your pluginsFile. If that's the case, restart the test runner.

Please fix this, or set pluginsFile to false if a plugins file is not necessary for your project.

Error: Cannot find module 'cypress-cucumber-preprocessor'

like image 914
Delwin Horsthemke Avatar asked Dec 05 '25 10:12

Delwin Horsthemke


2 Answers

My problem was solved by installing latest cypress types

npm i -D @types/cypress@latest

like image 95
Akshay Vijay Jain Avatar answered Dec 08 '25 14:12

Akshay Vijay Jain


I added the following tsconfig.json file an ran npm i -D @types/cypress@latest worked for me.

{
    "compilerOptions": {
      "target": "es5",
      "lib": ["es5", "dom"],
      "types": ["cypress", "node"]
    },
    "include": ["**/*.ts"]
  }
like image 26
Jayashani Mandila Avatar answered Dec 08 '25 15:12

Jayashani Mandila



Donate For Us

If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!