Skip to content

Installing with npm v7 fails for React Native 0.64 #7187

@fiznool

Description

@fiznool

🐛 Bug Report

Installing library with React Native 0.64 and npm7 fails due to a peer dependency error.

Screenshot 2021-07-15 at 12 09 24

Have you read the Contributing Guidelines on issues?

Yes

To Reproduce

(Write your steps here:)

  1. Install node and npm 7: npm install -g npm@7
  2. Create a new react native project, telling the script to use npm as the package manager: npx react-native init NavigationProject --npm
  3. Go into the new folder and try to install react-native-navigation: cd NavigationProject; npm install react-native-navigation

Expected behavior

Install should succeed

Actual Behavior

Install failed.

On further inspection, this is due to the following:

  • react-native-navigation has a dependency on remx@3.x.x
  • This resolves to remx@3.0.611, which has a dependency on mobx-react@^5.2.3
  • This resolves to mobx-react@5.4.4, which has a peerDependency on react@"^0.13.0 || ^0.14.0 || ^15.0.0 || ^16.0.0" (note: not react@17)

Since React Native 0.64 has a peer dependency on React 17, this is the version installed when running npx react-native init. npm v7's default behaviour when a peer dependency can't be fulfilled is to fail the installation, which is what is happening in this case: mobx-react@5.4.4 does not list react@17 as a peerDep.

There is a workaround, to run npm install --legacy-peer-deps which reverts back to npm v6 behaviour - but this isn't particularly elegant.

Your Environment

  • React Native Navigation version: 7.18.0
  • React Native version: 0.64.2
  • Platform(s) (iOS, Android, or both?): both
  • Device info (Simulator/Device? OS version? Debug/Release?): N/A
  • Node version: 14.16.1
  • npm version: 7.9.0

Reproducible Demo

(Paste the link to an example repo and exact instructions to reproduce the issue.)

https://github.com/studiozeffa/react-native-navigation-peerdep-issue

  • Clone the above
  • Make sure you are using npm v7 (npm install -g npm@7)
  • Run npm install

This will reproduce the issue.

Metadata

Metadata

Assignees

Type

No type
No fields configured for issues without a type.

Projects

No projects

Milestone

No milestone

Relationships

None yet

Development

No branches or pull requests

Issue actions