简体   繁体   中英

react-native metro throws error in traverseDependency, can package-lock.json be the reason?

The error I get is described here on github in detail. Basically the metro bundler fails with the following error:

error: bundling failed: TypeError: Cannot read property 'map' of undefined at resolveDependencies (C:\\Apps\\MyProject\\rnw\\node_modules\\metro\\src\\DeltaBundler\\traverseDependencies.js:370:18) at C:\\Apps\\MyProject\\rnw\\node_modules\\metro\\src\\DeltaBundler\\traverseDependencies.js:188:33 at Generator.next () at step (C:\\Apps\\MyProject\\rnw\\node_modules\\metro\\src\\DeltaBundler\\traverseDependencies.js:298:30) at C:\\Apps\\MyProject\\rnw\\node_modules\\metro\\src\\DeltaBundler\\traverseDependencies.js:309:15 at DELTA [android, dev] ....../index.js ▓▓░░░░░░░░░░░░░░ 14.7% (221/612), failed.

This error message does not help me much, as I am not deep into how the metro bundler works.

So I checked recent changes I did in the code, eg I added the following to my project:

"react-native-tab-view": "^1.3.2",

After that, I have a weird change in package-lock.json. It seems react-native-tab-view was already existing there, I guess because it is a dependency of another project I imported before. Here is the first change in package-lock.json:

首先更改 package-lock.json

Ok so whatever, this looks still ok to me. What is weird is the second change I see:

package-lock.json 中的第二个变化

Wait, what? A dependency to react-native-tab-view was added to react-navigation-deprecated-tab-navigator with the old version number 0.0.77? That looks strange, at least for me.

Can somebody help me out here - is this change normal, or can this be the reason why metro bundler fails?

Any input appreciated!

No Need to Empty whole folder I solved the issue by deleting only one folder metro-cache

Path : C:\\Users\\Harsh1311\\AppData\\Local\\Temp

我通过清空C:\\ Users \\\\ AppData \\ Local \\ Temp文件夹解决了该问题。

The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM