Skip to content
Advertisement

Cypress: Module not found: Error: Can’t resolve ‘cypress-wait-util’

I’m using Cypress 7.5 and trying to use cypress-wait-until.

What I did is:

  1. Run npm i -D cypress-wait-until
  2. Add import 'cypress-wait-until'; to cypress/support/commands/index.js file

Now, I’m not able to run tests due to the following error:

Error: Webpack Compilation Error
./cypress/support/commands/index.js
Module not found: Error: Can't resolve 'cypress-wait-util' in 'E:projectcypresssupportcommands'
resolve 'cypress-wait-util' in 'E:projectcypresssupportcommands'
  Parsed request is a module
  using description file: E:projectpackage.json (relative path: ./cypress/support/commands)
    Field 'browser' doesn't contain a valid alias configuration
    Looked for and couldn't find the file at the following paths:
[E:projectcypresssupportcommandsnode_modules]
[E:projectcypresssupportnode_modules]
[E:projectcypressnode_modules]
[E:node_modules]
[E:projectnode_modulescypress-wait-util]
[E:projectnode_modulescypress-wait-util.js]
[E:projectnode_modulescypress-wait-util.json]
[E:projectnode_modulescypress-wait-util.jsx]
[E:projectnode_modulescypress-wait-util.mjs]
[E:projectnode_modulescypress-wait-util.coffee]
 @ ./cypress/support/commands/index.js 3:0-28
 @ ./cypress/support/index.js
 
    at Watching.handle [as handler] (C:UsersDevAppDataLocalCypressCache7.5.0Cypressresourcesapppackagesservernode_modules@cypresswebpack-preprocessordistindex.js:172:23)
    at C:UsersDevAppDataLocalCypressCache7.5.0Cypressresourcesapppackagesservernode_moduleswebpacklibWatching.js:99:9
    at AsyncSeriesHook.eval [as callAsync] (eval at create (C:UsersDevAppDataLocalCypressCache7.5.0Cypressresourcesapppackagesservernode_modulestapablelibHookCodeFactory.js:33:10), <anonymous>:6:1)
    at Watching._done (C:UsersDevAppDataLocalCypressCache7.5.0Cypressresourcesapppackagesservernode_moduleswebpacklibWatching.js:98:28)
    at C:UsersDevAppDataLocalCypressCache7.5.0Cypressresourcesapppackagesservernode_moduleswebpacklibWatching.js:73:19
    at Compiler.emitRecords (C:UsersDevAppDataLocalCypressCache7.5.0Cypressresourcesapppackagesservernode_moduleswebpacklibCompiler.js:499:39)
    at C:UsersDevAppDataLocalCypressCache7.5.0Cypressresourcesapppackagesservernode_moduleswebpacklibWatching.js:54:20
    at C:UsersDevAppDataLocalCypressCache7.5.0Cypressresourcesapppackagesservernode_moduleswebpacklibCompiler.js:485:14
    at AsyncSeriesHook.eval [as callAsync] (eval at create (C:UsersDevAppDataLocalCypressCache7.5.0Cypressresourcesapppackagesservernode_modulestapablelibHookCodeFactory.js:33:10), <anonymous>:6:1)
    at C:UsersDevAppDataLocalCypressCache7.5.0Cypressresourcesapppackagesservernode_moduleswebpacklibCompiler.js:482:27
    at C:UsersDevAppDataLocalCypressCache7.5.0Cypressresourcesapppackagesservernode_modulesneo-asyncasync.js:2818:7
    at done (C:UsersDevAppDataLocalCypressCache7.5.0Cypressresourcesapppackagesservernode_modulesneo-asyncasync.js:3522:9)
    at AsyncSeriesHook.eval [as callAsync] (eval at create (C:UsersDevAppDataLocalCypressCache7.5.0Cypressresourcesapppackagesservernode_modulestapablelibHookCodeFactory.js:33:10), <anonymous>:6:1)
    at C:UsersDevAppDataLocalCypressCache7.5.0Cypressresourcesapppackagesservernode_moduleswebpacklibCompiler.js:464:33
    at C:UsersDevAppDataLocalCypressCache7.5.0Cypressresourcesapppackagesservernode_modulesgraceful-fsgraceful-fs.js:111:16
    at C:UsersDevAppDataLocalCypressCache7.5.0Cypressresourcesapppackagesservernode_modulesenhanced-resolvenode_modulesgraceful-fsgraceful-fs.js:61:14

Advertisement

Answer

I had to specify the correct URL for the package installed inside node_modules. like:

import '../../../node_modules/cypress-wait-util';
User contributions licensed under: CC BY-SA
1 People found this is helpful
Advertisement