Skip to content

Metro 0.25+ is resolving package.json within react-native/.../__fixtures__ directory #139

Description

@jamesreggio

Do you want to request a feature or report a bug?

Bug

What is the current behavior?

I have an actual dependency upon react-native-vector-icons in my React Native project.

(I'm on RN 0.52.0, but I've manually upgraded to metro@0.26.0 and metro-core@0.26.0 using yarn's resolutions feature.)

React Native includes a package.json for react-native-vector-icons as a test fixture here: https://github.com/facebook/react-native/blob/master/local-cli/core/__fixtures__/files/package.json

(It's been there for a long while.)

In Metro 0.25.1 onwards, the packager will resolve the fixture version of react-native-vector-icons, instead of resolving the actual package at the root of my node_modules. Because the fixture doesn't contain the full source, the packager spits out this error:

error: bundling failed: Error: While trying to resolve module `react-native-vector-icons` from file `/Users/jamesreggio/src/banter/mobile/js/components/controls/core/Icon.js`, the package `/Users/jamesreggio/src/banter/mobile/node_modules/react-native/loc
al-cli/core/__fixtures__/files/package.json` was successfully found. However, this package itself specifies a `main` module field that could not be resolved (`/Users/jamesreggio/src/banter/mobile/node_modules/react-native/local-cli/core/__fixtures__/files
/index.js`. Indeed, none of these files exist:

  * `/Users/jamesreggio/src/banter/mobile/node_modules/react-native/local-cli/core/__fixtures__/files/index.js(.native||.ios.js|.native.js|.js|.ios.json|.native.json|.json)`
  * `/Users/jamesreggio/src/banter/mobile/node_modules/react-native/local-cli/core/__fixtures__/files/index.js/index(.native||.ios.js|.native.js|.js|.ios.json|.native.json|.json)`
    at ResolutionRequest.resolveDependency (/Users/jamesreggio/src/banter/mobile/node_modules/metro/src/node-haste/DependencyGraph/ResolutionRequest.js:108:15)
    at DependencyGraph.resolveDependency (/Users/jamesreggio/src/banter/mobile/node_modules/metro/src/node-haste/DependencyGraph.js:270:4419)
    at /Users/jamesreggio/src/banter/mobile/node_modules/metro/src/DeltaBundler/traverseDependencies.js:201:36
    at Generator.next (<anonymous>)
    at step (/Users/jamesreggio/src/banter/mobile/node_modules/metro/src/DeltaBundler/traverseDependencies.js:256:306)
    at /Users/jamesreggio/src/banter/mobile/node_modules/metro/src/DeltaBundler/traverseDependencies.js:256:536
    at new Promise (<anonymous>)
    at /Users/jamesreggio/src/banter/mobile/node_modules/metro/src/DeltaBundler/traverseDependencies.js:256:217
    at addDependency (/Users/jamesreggio/src/banter/mobile/node_modules/metro/src/DeltaBundler/traverseDependencies.js:256:92)
    at /Users/jamesreggio/src/banter/mobile/node_modules/metro/src/DeltaBundler/traverseDependencies.js:237:9

What is the expected behavior?

I would expect Metro to resolve to the node_modules/react-native-vector-icons/package.json first, and thus silently succeed in bundling.

Please provide your exact Metro configuration and mention your Metro, node, yarn/npm version and operating system.

I'm on RN 0.52.0, but I've manually upgraded to metro@0.26.0 and metro-core@0.26.0 using yarn's resolutions feature.

yarn 1.3.2
Mac OS X 10.12.6 (High Sierra)

Activity

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Metadata

Metadata

Assignees

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