Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

React monorepo preset base configuration contains conflicting peer dependency #28191

Closed
1 of 4 tasks
Revinz opened this issue Sep 29, 2024 · 12 comments · Fixed by #28559
Closed
1 of 4 tasks

React monorepo preset base configuration contains conflicting peer dependency #28191

Revinz opened this issue Sep 29, 2024 · 12 comments · Fixed by #28559
Assignees
Labels
scope: react Issues related to React support for Nx type: bug

Comments

@Revinz
Copy link

Revinz commented Sep 29, 2024

Current Behavior

Creating a workspace with react-monorepo preset leads to "npm i" and future npm package installations to give a conflicting peer dependency error.

Expected Behavior

Ability to install new packages and generate node modules using npm install

GitHub Repo

No response

Steps to Reproduce

  1. npx create-nx-workspace@latest test --preset=react-monorepo
  2. Application name irrelevant
  3. Bundler=Rspack
  4. Testrunner=None
  5. Stylesheet format=styled-components
  6. CI=GitHub Actions
  7. Navigate to workspace root
  8. run npm install
  9. Error: While resolving: [email protected]

Edit: Also occurs with Vite and Webpack as bundler. Both results in the same error, meaning this is a major issue as the preset do not work at all.

Nx Report

Node           : 18.16.0
OS             : win32-x64
Native Target  : x86_64-windows
npm            : 9.5.1

nx (global)        : 17.1.1
nx                 : 19.8.2
@nx/js             : 19.8.2
@nx/jest           : 19.8.2
@nx/linter         : 19.8.2
@nx/eslint         : 19.8.2
@nx/workspace      : 19.8.2
@nx/devkit         : 19.8.2
@nx/eslint-plugin  : 19.8.2
@nx/react          : 19.8.2
@nrwl/tao          : 19.8.2
@nx/web            : 19.8.2
typescript         : 5.5.4
---------------------------------------
Registered Plugins:
@nx/eslint/plugin
@nx/jest/plugin
---------------------------------------
Community plugins:
@nx/rspack : 19.8.0

Failure Logs

npm ERR! code ERESOLVE
npm ERR! ERESOLVE could not resolve
npm ERR!
npm ERR! While resolving: [email protected]
npm ERR! Found: [email protected]
npm ERR! node_modules/eslint
npm ERR!   dev eslint@"^9.8.0" from the root project
npm ERR!   peer eslint@"^6.0.0 || ^7.0.0 || >=8.0.0" from @eslint-community/[email protected]
npm ERR!   node_modules/@eslint-community/eslint-utils
npm ERR!     @eslint-community/eslint-utils@"^4.4.0" from @typescript-eslint/[email protected]
npm ERR!     node_modules/@typescript-eslint/utils
npm ERR!       @typescript-eslint/utils@"^8.0.0" from @nx/[email protected]
npm ERR!       node_modules/@nx/eslint-plugin
npm ERR!         dev @nx/eslint-plugin@"19.8.2" from the root project
npm ERR!         1 more (@nrwl/eslint-plugin-nx)
npm ERR!       3 more (@typescript-eslint/eslint-plugin, ...)
npm ERR!     @eslint-community/eslint-utils@"^4.2.0" from [email protected]
npm ERR!   6 more (@nx/eslint, @typescript-eslint/eslint-plugin, ...)
npm ERR!
npm ERR! Could not resolve dependency:
npm ERR! peer eslint@"^2 || ^3 || ^4 || ^5 || ^6 || ^7.2.0 || ^8" from [email protected]
npm ERR! node_modules/eslint-plugin-import
npm ERR!   dev eslint-plugin-import@"2.30.0" from the root project
npm ERR!
npm ERR! Conflicting peer dependency: [email protected]
npm ERR! node_modules/eslint
npm ERR!   peer eslint@"^2 || ^3 || ^4 || ^5 || ^6 || ^7.2.0 || ^8" from [email protected]
npm ERR!   node_modules/eslint-plugin-import
npm ERR!     dev eslint-plugin-import@"2.30.0" from the root project
npm ERR!
npm ERR! Fix the upstream dependency conflict, or retry
npm ERR! this command with --force or --legacy-peer-deps
npm ERR! to accept an incorrect (and potentially broken) dependency resolution.

Package Manager Version

No response

Operating System

  • macOS
  • Linux
  • Windows
  • Other (Please specify)

Additional Information

Related issue from eslint-plugin-import regarding eslint v9 support can be found here. Includes potential workaround that I have not tested: import-js/eslint-plugin-import#2948

The issue that have introduced this problem is most likely this one: #27451

@Revinz Revinz changed the title React monorepo with Rspack base configuration contains conflicting peer dependency React monorepo preset base configuration contains conflicting peer dependency Sep 29, 2024
@ziacik
Copy link
Contributor

ziacik commented Sep 30, 2024

Also, @nx/[email protected] uses esbuild@~0.19.2 as peer dep
while @nx/[email protected] installs [email protected] which uses esbuild@^0.21.3 as dep,
bringing two sets of binaries to node_modules.

This is hell. :(

@jeff-edmondson-pci
Copy link

Seeing this as well. Is there any resolution?

@lundinmathias
Copy link

lundinmathias commented Oct 2, 2024

I ran into this as well while following the tutorial https://nx.dev/getting-started/tutorials/react-monorepo-tutorial. Used --legacy-peer-deps to be able to move on.

@Bullfrog1234
Copy link

So doing a bit of research I have found the following

Packages with support for ESLint v9

Packages without support for ESLint v9

eslint-plugin-react-hooks

The issue is eslint-plugin-react-hooks it has no support for v9 of ESLint. There is anan open issue (react#28313) which talks about the flat file nature of v9 and a PR react#30774 that add support for a flat configuration. This however does not include an updated peer dependencies for v9 in the package.

Temporary Solution

Add an override for eslint-plugin-react-hooks in package.json:

{
 "name": "@demo/source",
  "version": "0.0.0",
  "devDependencies":{
    "eslint": "^9.8.0",
    "eslint-config-prettier": "^9.0.0",
    "eslint-plugin-import": "2.31.0",
    "eslint-plugin-jsx-a11y": "6.10.0",
    "eslint-plugin-react": "7.37.1",
    "eslint-plugin-react-hooks": "4.6.0",
  },
  "overrides": {
    "eslint-plugin-react-hooks": {
      "eslint": "^9.8.0"
    }
  }
}

@rteano
Copy link

rteano commented Oct 4, 2024

Experiencing this issue as well even without using a preset, but by just adding the react-app via nx g @nx/react:app app --bundler=vite

Would it be safe to downgrade eslint instead?

@isaacplmann
Copy link
Collaborator

Should be resolved by #28267

@Bullfrog1234
Copy link

Should be resolved by #28267

@isaacplmann This does not fix all the peer dependency issues that are caused by the upgrade. Additionally, some of the plugins do not support v9 see above

@trumbitta
Copy link
Contributor

I'm still having the issue with Nx 20.0.0

npm error code ERESOLVE
npm error ERESOLVE could not resolve
npm error
npm error While resolving: [email protected]
npm error Found: [email protected]
npm error node_modules/eslint
npm error   dev eslint@"^9.8.0" from the root project
npm error   peer eslint@"^6.0.0 || ^7.0.0 || >=8.0.0" from @eslint-community/[email protected]
npm error   node_modules/@eslint-community/eslint-utils
npm error     @eslint-community/eslint-utils@"^4.4.0" from @typescript-eslint/[email protected]
npm error     node_modules/@typescript-eslint/utils
npm error       @typescript-eslint/utils@"^8.0.0" from @nx/[email protected]
npm error       node_modules/@nx/eslint-plugin
npm error         dev @nx/eslint-plugin@"20.0.0" from the root project
npm error       3 more (@typescript-eslint/eslint-plugin, ...)
npm error     @eslint-community/eslint-utils@"^4.2.0" from [email protected]
npm error   8 more (@eslint/compat, @nx/eslint, ...)
npm error
npm error Could not resolve dependency:
npm error peer eslint@"^3 || ^4 || ^5 || ^6 || ^7 || ^8" from [email protected]
npm error node_modules/eslint-plugin-jsx-a11y
npm error   dev eslint-plugin-jsx-a11y@"6.7.1" from the root project
npm error
npm error Conflicting peer dependency: [email protected]
npm error node_modules/eslint
npm error   peer eslint@"^3 || ^4 || ^5 || ^6 || ^7 || ^8" from [email protected]
npm error   node_modules/eslint-plugin-jsx-a11y
npm error     dev eslint-plugin-jsx-a11y@"6.7.1" from the root project
npm error
 NX   Report complete - copy this into the issue template

Node           : 20.17.0
OS             : darwin-arm64
Native Target  : aarch64-macos
npm            : 10.8.2

nx                 : 20.0.0
@nx/js             : 20.0.0
@nx/jest           : 20.0.0
@nx/eslint         : 20.0.0
@nx/workspace      : 20.0.0
@nx/devkit         : 20.0.0
@nx/eslint-plugin  : 20.0.0
@nx/react          : 20.0.0
@nx/rspack         : 20.0.0
@nx/web            : 20.0.0
typescript         : 5.5.4
---------------------------------------
Registered Plugins:
@nx/eslint/plugin
@nx/jest/plugin

@isaacplmann
Copy link
Collaborator

isaacplmann commented Oct 8, 2024

Can confirm the issue is happening in Nx 20. We're a little slow this week since the whole team is at Monorepo World.

@Bullfrog1234 's workaround should work for v20 as well.

@sacru2red
Copy link

sacru2red commented Oct 14, 2024

eslint-plugin-react-hooks start to support eslint v9
https://github.com/facebook/react/releases/tag/eslint-plugin-react-hooks%405.0.0

I got errors with Nx Monorepo tutorial

resolve with npm install eslint-plugin-jsx-a11y@latest eslint-plugin-react-hooks@latest

@jaysoo jaysoo self-assigned this Oct 14, 2024
@jaysoo jaysoo added the scope: react Issues related to React support for Nx label Oct 14, 2024
@laszlo-ratesic
Copy link

laszlo-ratesic commented Oct 14, 2024

@Bullfrog1234's workaround didn't fully solve it for me as I'm using the nextjs starter, but I had the same peer conflicting deps error. I was able to install packages with --legacy-peer-deps but ran into issues when trying to use shadcn/ui CLI so I needed something that would work without the flag.

I ended up changing my package.json's devDependencies and overrides to this

"devDependencies": {
    // other dependencies...
    "@typescript-eslint/eslint-plugin": "^7.2.0",
    "@typescript-eslint/parser": "^7.2.0",
    "eslint": "8.56.0",
    "eslint-config-next": "14.2.3",
  },
  "overrides": {
    "eslint": "8.56.0",
    "@typescript-eslint/eslint-plugin": {
      "eslint": "8.56.0"
    },
    "@typescript-eslint/parser": {
      "eslint": "8.56.0"
    }
  }

Then I ran npm clean cache --force and then npm install and it worked like a charm for me.

@jaysoo
Copy link
Member

jaysoo commented Oct 22, 2024

You can manually update eslint-plugin-react-hooks and eslint-plugin-jsx-a11y to 5.0.0 and 6.10.1 respectively which will resolve the peer dep conflict.

We'll make the the versions are updated in Nx 20.1.

jaysoo added a commit that referenced this issue Oct 22, 2024
<!-- Please make sure you have read the submission guidelines before
posting an PR -->
<!--
https://github.com/nrwl/nx/blob/master/CONTRIBUTING.md#-submitting-a-pr
-->

<!-- Please make sure that your commit message follows our format -->
<!-- Example: `fix(nx): must begin with lowercase` -->

<!-- If this is a particularly complex change or feature addition, you
can request a dedicated Nx release for this pull request branch. Mention
someone from the Nx team or the `@nrwl/nx-pipelines-reviewers` and they
will confirm if the PR warrants its own release for testing purposes,
and generate it for you if appropriate. -->

## Current Behavior
<!-- This is the behavior we have today -->

## Expected Behavior
<!-- This is the behavior we should expect with the changes in this PR
-->

## Related Issue(s)
<!-- Please link the issue being fixed so it gets closed when this is
merged. -->

Fixes #28191
jaysoo added a commit that referenced this issue Oct 25, 2024
<!-- Please make sure you have read the submission guidelines before
posting an PR -->
<!--
https://github.com/nrwl/nx/blob/master/CONTRIBUTING.md#-submitting-a-pr
-->

<!-- Please make sure that your commit message follows our format -->
<!-- Example: `fix(nx): must begin with lowercase` -->

<!-- If this is a particularly complex change or feature addition, you
can request a dedicated Nx release for this pull request branch. Mention
someone from the Nx team or the `@nrwl/nx-pipelines-reviewers` and they
will confirm if the PR warrants its own release for testing purposes,
and generate it for you if appropriate. -->

<!-- This is the behavior we have today -->

<!-- This is the behavior we should expect with the changes in this PR
-->

<!-- Please link the issue being fixed so it gets closed when this is
merged. -->

Fixes #28191
jaysoo added a commit that referenced this issue Oct 25, 2024
<!-- Please make sure you have read the submission guidelines before
posting an PR -->
<!--
https://github.com/nrwl/nx/blob/master/CONTRIBUTING.md#-submitting-a-pr
-->

<!-- Please make sure that your commit message follows our format -->
<!-- Example: `fix(nx): must begin with lowercase` -->

<!-- If this is a particularly complex change or feature addition, you
can request a dedicated Nx release for this pull request branch. Mention
someone from the Nx team or the `@nrwl/nx-pipelines-reviewers` and they
will confirm if the PR warrants its own release for testing purposes,
and generate it for you if appropriate. -->

<!-- This is the behavior we have today -->

<!-- This is the behavior we should expect with the changes in this PR
-->

<!-- Please link the issue being fixed so it gets closed when this is
merged. -->

Fixes #28191
jaysoo added a commit that referenced this issue Oct 25, 2024
<!-- Please make sure you have read the submission guidelines before
posting an PR -->
<!--
https://github.com/nrwl/nx/blob/master/CONTRIBUTING.md#-submitting-a-pr
-->

<!-- Please make sure that your commit message follows our format -->
<!-- Example: `fix(nx): must begin with lowercase` -->

<!-- If this is a particularly complex change or feature addition, you
can request a dedicated Nx release for this pull request branch. Mention
someone from the Nx team or the `@nrwl/nx-pipelines-reviewers` and they
will confirm if the PR warrants its own release for testing purposes,
and generate it for you if appropriate. -->

<!-- This is the behavior we have today -->

<!-- This is the behavior we should expect with the changes in this PR
-->

<!-- Please link the issue being fixed so it gets closed when this is
merged. -->

Fixes #28191
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
scope: react Issues related to React support for Nx type: bug
Projects
None yet
Development

Successfully merging a pull request may close this issue.