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

fix: add React 16 & 18 to peer dependencies #277

Closed
wants to merge 2 commits into from

Conversation

nolanleung
Copy link

npm install fails when using React 18 because it is missing from peer dependencies.

@codesandbox-ci
Copy link

codesandbox-ci bot commented Aug 1, 2022

This pull request is automatically built and testable in CodeSandbox.

To see build info of the built libraries, click here or the icon next to each commit SHA.

Latest deployment of this branch, based on commit a160e10:

Sandbox Source
React Configuration
React Typescript Configuration
examples Configuration

@michalochman
Copy link
Owner

Hi @nolanleung, can you please explain why do you think it is needed and provide more context into where do you execute the npm install command? Please include the error message if possible.

This library works with all React versions greater or equal to 16, not just 18, so adding version 18 to dependencies would be confusing.

@saricden
Copy link

saricden commented Aug 2, 2022

@michalochman I'm encountering the same issue.

When using React version 18, react-pixi-fiber fails to install. The output of the installation command is as follows:

npm ERR! code ERESOLVE
npm ERR! ERESOLVE unable to resolve dependency tree
npm ERR! 
npm ERR! While resolving: [email protected]
npm ERR! Found: [email protected]
npm ERR! node_modules/react
npm ERR!   react@"^18.2.0" from the root project
npm ERR! 
npm ERR! Could not resolve dependency:
npm ERR! peer react@"^17.0.0" from [email protected]
npm ERR! node_modules/react-pixi-fiber
npm ERR!   react-pixi-fiber@"1.0.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.
npm ERR! 
npm ERR! See /home/kirk/.npm/eresolve-report.txt for a full report.

npm ERR! A complete log of this run can be found in:
npm ERR!     /home/kirk/.npm/_logs/2022-08-02T01_21_21_562Z-debug-0.log

@nolanleung
Copy link
Author

nolanleung commented Aug 2, 2022

Hey @michalochman thanks for the reply!

Since peerDependencies[0] defined in the package.json explicitly requires ^17.0.0, neither react versions 16 nor 18 will be allowed. We can use the logical or operator[1] to allow versions 16 || 17 || 18 or by using the range operator 16 - 18.

You can try yourself with the following:

React 16

{
  "name": "react-pixi-dep",
  "version": "0.1.0",
  "private": true,
  "scripts": {},
  "dependencies": {
    "react": "^16.4.0",
    "react-dom": "^16.4.0"
  },
  "devDependencies": {
    "@types/node": "18.6.3",
    "@types/react": "^16.4.0",
    "@types/react-dom": "^16.4.0"
  }
}

Running npm install fails with

npm ERR! code ERESOLVE
npm ERR! ERESOLVE unable to resolve dependency tree
npm ERR! 
npm ERR! While resolving: [email protected]
npm ERR! Found: [email protected]
npm ERR! node_modules/react
npm ERR!   react@"^16.4.0" from the root project
npm ERR! 
npm ERR! Could not resolve dependency:
npm ERR! peer react@"^17.0.0" from [email protected]
npm ERR! node_modules/react-pixi-fiber
npm ERR!   react-pixi-fiber@"*" from the root project

React 18

{
  "name": "react-pixi-dep",
  "version": "0.1.0",
  "private": true,
  "scripts": {},
  "dependencies": {
    "react": "^18.0.0",
    "react-dom": "^18.0.0"
  },
  "devDependencies": {
    "@types/node": "18.6.3",
    "@types/react": "^18.0.0",
    "@types/react-dom": "^18.0.0"
  }
}

Running npm install fails with

npm ERR! code ERESOLVE
npm ERR! ERESOLVE unable to resolve dependency tree
npm ERR! 
npm ERR! While resolving: [email protected]
npm ERR! Found: [email protected]
npm ERR! node_modules/react
npm ERR!   react@"^18.0.0" from the root project
npm ERR! 
npm ERR! Could not resolve dependency:
npm ERR! peer react@"^17.0.0" from [email protected]
npm ERR! node_modules/react-pixi-fiber
npm ERR!   react-pixi-fiber@"*" from the root project

[0] https://docs.npmjs.com/cli/v8/configuring-npm/package-json#peerdependencies
[1] https://docs.npmjs.com/cli/v8/configuring-npm/package-json#dependencies

@nolanleung nolanleung changed the title fix: add React 18 to peer dependencies fix: add React 16 & 18 to peer dependencies Aug 2, 2022
@saricden
Copy link

saricden commented Aug 2, 2022

:shipit:

@saricden
Copy link

saricden commented Aug 2, 2022

@michalochman when do you reckon this'll be merged and published to NPM?

I really want to start using react-pixi-fiber on my project, but it's React 18 so until this goes through I'm outta luck.

@michalochman
Copy link
Owner

michalochman commented Aug 2, 2022

Good point @nolanleung, I totally forgot version 17 was specified and didn't check before writing my comment, apologies for that and thank you for reporting the issue.

I will update it with >=16.0.0 range so we don't have to maintain it. I will close this pull request so I can do this immediately.

@michalochman
Copy link
Owner

Fixed in [email protected].

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

3 participants