Skip to content

bug: npm doesn't resolve this package properly when using React Native #2988

@mikewli

Description

@mikewli

Provide environment information

System:
OS: macOS 12.5
CPU: (10) arm64 Apple M1 Pro
Memory: 2.80 GB / 16.00 GB
Shell: 5.8.1 - /bin/zsh
Binaries:
Node: 16.17.0 - ~/.nodenv/versions/16.17.0/bin/node
Yarn: 1.22.19 - ~/.nodenv/versions/16.17.0/bin/yarn
npm: 8.15.0 - ~/.nodenv/versions/16.17.0/bin/npm
Watchman: 2022.10.03.00 - /opt/homebrew/bin/watchman
Browsers:
Chrome: 106.0.5249.103
Firefox: 105.0.3
Safari: 15.6
npmPackages:
react: 18.1.0 => 18.1.0
trpcroot: undefined
typescript: ^4.8.2 => 4.8.4

Describe the bug

npm ERR! code ERESOLVE
npm ERR! ERESOLVE unable to resolve dependency tree
npm ERR! 
npm ERR! While resolving: ReactNativetRPC@0.0.1
npm ERR! Found: react@18.1.0
npm ERR! node_modules/react
npm ERR!   react@"18.1.0" from the root project
npm ERR!   peer react@">=16.8.0" from @trpc/react@9.27.4
npm ERR!   node_modules/@trpc/react
npm ERR!     dev @trpc/react@"^9.27.2" from the root project
npm ERR! 
npm ERR! Could not resolve dependency:
npm ERR! peer react@"^18.2.0" from react-dom@18.2.0
npm ERR! node_modules/react-dom
npm ERR!   peer react-dom@">=16.8.0" from @trpc/react@9.27.4
npm ERR!   node_modules/@trpc/react
npm ERR!     dev @trpc/react@"^9.27.2" 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.

Link to reproduction

https://github.com/mikewli/ReactNativetRPC

To reproduce

You can use the repository I've created here to reproduce things.
https://github.com/mikewli/ReactNativetRPC

Run

npm install

to see the error for including tRPC in a starter React Native project.

Additional information

The solution I'm presenting here is to move certain dependencies into the devDependencies area, so that they do not have to be included in a developer's repository if their code does not need it.

See https://github.com/mikewli/trpc/commit/be43572687eeb93aacd3e34a2800b0148a0f11bd for my solution on this.

👨‍👧‍👦 Contributing

  • 🙋‍♂️ Yes, I'd be down to file a PR fixing this bug!

Metadata

Metadata

Assignees

No one assigned

    Labels

    No labels
    No labels

    Type

    No type

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions