cypress: Module not found: Error: Can't resolve '@cypress/xpath'

Current behavior

Followed instructions for installing @cypress/xpath included require('@cypress/xpath') in support file. Encountered error running tests in Electron (but browser isnt really relevent):

Error: Webpack Compilation Error
Module not found: Error: Can't resolve '@cypress/xpath'

Desired behavior

Update package.json in @cypress/xpath to export correctly

Test code to reproduce

  1. npm install -D @cypress/xpath
  2. add require('@cypress/xpath'); to support file
  3. run tests

Cypress Version

10.6.0

Node version

v16.14.0

Operating System

macOS 12.6

Debug Logs

No response

Other

No response

About this issue

  • Original URL
  • State: closed
  • Created 2 years ago
  • Reactions: 2
  • Comments: 17 (1 by maintainers)

Most upvoted comments

I’m also facing the same issue, following steps in readme

I was able to resolve the issue by:

  1. ran command npm install -D cypress-xpath

  2. in the folder cypress/support/e2e at the top of the file typed require(‘cypress-xpath’); Screen Shot 2022-10-22 at 9 17 10

  3. and at the cypress/e2e in my test at the top I placed the following command /// <reference types="cypress-xpath" /> Screen Shot 2022-10-22 at 9 18 00

@jordanpowell88 Thank you for taking a look at this issue, the repo unfortunately is private. I can set up a minimal example if needed.

Examining the node packages installed though, in the package.json for @cypress/xpath main is set to scripts and scripts is not supplied in the package.

Screenshot 2022-10-13 at 14 26 08