question-mark
Stuck on an issue?

Lightrun Answers was designed to reduce the constant googling that comes with debugging 3rd party libraries. It collects links to all the places you might be looking at while hunting down a tough bug.

And, if you’re still stuck at the end, we’re happy to hop on a call to see how we can help out.

Peer dependency issue - @cypress/webpack-preprocessor doesn't support webpack@^5

See original GitHub issue

Current behavior

Installation of @cypress/react fails due to unresolved peer dependency.

Pre-existing install of webpack 5 & react 17

From a repository with the following packages:

  "dependencies": {
    "html-webpack-plugin": "^5.3.1",
    "react": "^17.0.2",
    "react-dom": "^17.0.2",
    "webpack": "^5.36.2",
    "webpack-cli": "^4.7.0",
    "webpack-dev-server": "^3.11.2"
  }

when running the cypress guide command (minus webpack-dev-server):

npm install --save-dev cypress @cypress/react @cypress/webpack-dev-server

install fails with error: “Enable to resolve dependency tree” (see below screenshot) The culprit seems to be @cypress/webpack-preprocessor which can’t support a webpack version greater than 4.

Screen-Shot-2021-05-07-at-11-51-01-AM

Pre-existing install of react 17 only

From an empty repository, the install fails due to html-webpack-plugin ^5.3.1 needing webpack 5 rather than webpack 4

command

npm install --save-dev cypress @cypress/react @cypress/webpack-dev-server webpack-dev-server

Logs Screen-Shot-2021-05-07-at-1-49-44-PM

Pre-existing install of react 17 & html-webpack-plugin 4

From the only the following repository, the install works:

  "dependencies": {
    "html-webpack-plugin": "^4.5.2",
    "react": "^17.0.2",
    "react-dom": "^17.0.2",
  }

command

npm install --save-dev cypress @cypress/react @cypress/webpack-dev-server webpack-dev-server

Logs Screen-Shot-2021-05-07-at-1-57-52-PM

Environment

  • node: v14.16.0
  • npm: v7.11.2
  • Mac OS Big Sur version 11.3

Expected behavior

Clean install with support for webpack 5

Issue Analytics

  • State:closed
  • Created 2 years ago
  • Comments:5 (4 by maintainers)

github_iconTop GitHub Comments

1reaction
Laurent147commented, May 11, 2021

@lmiller1990 thanks for the very reactive fix. I tested the install on my side and all seems to work with the exact command suggested by your guide. Thanks!

0reactions
lmiller1990commented, May 11, 2021

Fixed in #16412, @cypress/react": "^5.6.0". It’s been released. I re-ran the above command and it worked.

Read more comments on GitHub >

github_iconTop Results From Across the Web

Webpack 5 support · Issue #8900 · cypress-io/cypress - GitHub
I've been using cypress-webpack-preprocessor with webpack 5 now for a bit and the only issue for us is the peer dependency warning. It...
Read more >
cypress-webpack-preprocessor-v5 - npm package - Snyk
This package relies on the following peer dependencies: @babel/core; @babel/preset-env; babel-loader; webpack. It is likely you already have ...
Read more >
@cypress/webpack-preprocessor - npm
Cypress preprocessor for bundling JavaScript via webpack. Latest version: 5.16.0, last published: 9 days ago.
Read more >
Migration Guide | Cypress Documentation
Migrating to Cypress 12.0 This guide details the changes and how to change your code to migrate to Cypress version 12.0.
Read more >
Problem setting up Cypress component tests for CRA with ...
@import '~src/styles/variables';. I'm not too familiar with Webpack so I'm not sure why this error is happening. :( The actual test for 1 ......
Read more >

github_iconTop Related Medium Post

No results found

github_iconTop Related StackOverflow Question

No results found

github_iconTroubleshoot Live Code

Lightrun enables developers to add logs, metrics and snapshots to live code - no restarts or redeploys required.
Start Free

github_iconTop Related Reddit Thread

No results found

github_iconTop Related Hackernoon Post

No results found

github_iconTop Related Tweet

No results found

github_iconTop Related Dev.to Post

No results found

github_iconTop Related Hashnode Post

No results found