sevenlops
sevenlops

Reputation: 486

Error: While trying to resolve module 'prop-types' from file

Error when I run the command react-native run-android. The error was on metro bundler, when, the app is installing on my device, always shows this error.

The curious thing is that only happens me in this PC, I used other PC for a long time and when I pull git repo here (previously I was able to develop and test on that PC too), it's impossible to get it working for this error...

I think that maybe could be I removed yarn.lock many days ago and when I run npm install here produces this error?

I ommited my path for logic reasons:

Loading dependency graph, done.
error: bundling failed: Error: While trying to resolve module `prop-types` from file `PATH_TO_PROJECT_FOLDER\node_modules\react-redux\lib\components\Provider.js`, the package `PATH_TO_PROJECT_FOLDER\node_modules\react-redux\node_modules\prop-types\package.json` was successfully found. However, this package itself specifies a `main` module field that could not be resolved (`PATH_TO_PROJECT_FOLDER\node_modules\react-redux\node_modules\prop-types\index`. Indeed, none of these files exist:

  * `PATH_TO_PROJECT_FOLDER\node_modules\react-redux\node_modules\prop-types\index(.native||.android.js|.native.js|.js|.android.json|.native.json|.json|.android.ts|.native.ts|.ts|.android.tsx|.native.tsx|.tsx)`
  * `PATH_TO_PROJECT_FOLDER\node_modules\react-redux\node_modules\prop-types\index\index(.native||.android.js|.native.js|.js|.android.json|.native.json|.json|.android.ts|.native.ts|.ts|.android.tsx|.native.tsx|.tsx)`
    at ResolutionRequest.resolveDependency (PATH_TO_PROJECT_FOLDER\node_modules\metro\src\node-haste\DependencyGraph\ResolutionRequest.js:65:15)
    at DependencyGraph.resolveDependency (PATH_TO_PROJECT_FOLDER\node_modules\metro\src\node-haste\DependencyGraph.js:283:16)
    at Object.resolve (PATH_TO_PROJECT_FOLDER\node_modules\metro\src\lib\transformHelpers.js:261:42)
    at dependencies.map.result (PATH_TO_PROJECT_FOLDER\node_modules\metro\src\DeltaBundler\traverseDependencies.js:399:31)
    at Array.map (<anonymous>)
    at resolveDependencies (PATH_TO_PROJECT_FOLDER\node_modules\metro\src\DeltaBundler\traverseDependencies.js:396:18)
    at PATH_TO_PROJECT_FOLDER\node_modules\metro\src\DeltaBundler\traverseDependencies.js:269:33
    at Generator.next (<anonymous>)
    at asyncGeneratorStep (PATH_TO_PROJECT_FOLDER\node_modules\metro\src\DeltaBundler\traverseDependencies.js:87:24)
    at _next (PATH_TO_PROJECT_FOLDER\node_modules\metro\src\DeltaBundler\traverseDependencies.js:107:9)
 DELTA  [android, dev] ..\..\../index.android.js ▓▓▓▓▓▓▓▓░░░░░░░░ 51.9% (610/847), failed.

react-native: 0.59.1

react-native-cli: 2.0.1

Upvotes: 0

Views: 4074

Answers (1)

sevenlops
sevenlops

Reputation: 486

Well.. I should not have deleted the yarn.lock file.

To fix:

  1. Delete all .lock files on root folder project as @hend-el-sahli said.
  2. yarn install
  3. If you had the error unable to resolve module ./index, see that thread https://github.com/facebook/react-native/issues/24112

:)

Upvotes: 3

Related Questions