How to fix React Native error “jest-haste-map: Has

2020-04-08 07:13发布

When I installed react-native-popup-menu, I faced such error.

This is error code

Looking for JS files in
E:\react-native\.............\

Loading dependency graph...(node:9460) UnhandledPromiseRejectionWarning: Error: jest-haste-map: Haste module naming collision: Duplicate module name: react-native Paths: E:\react-native\.............\node_modules\react-native-twitter-signin\node_modules\react-native\package.json collides with E:\react-native\.............\node_modules\react-native\package.json

This error is caused by hasteImpl returning the same name for different files. at setModule (E:\react-native\.............\node_modules\jest-haste-map\build\index.js:551:17) at workerReply (E:\react-native\.............\node_modules\jest-haste-map\build\index.js:613:9) at process._tickCallback (internal/process/next_tick.js:68:7) (node:9460) UnhandledPromiseRejectionWarning: Unhandled promise rejection. This error originated either by throwing inside of an async function without a catch block, or by rejecting a promise which was not handled with .catch(). (rejection id: 2) (node:9460) [DEP0018] DeprecationWarning: Unhandled promise rejections are deprecated. In the future, promise rejections that are not handled will terminate the Node.js process with a non-zero exit code. (node:9460) UnhandledPromiseRejectionWarning: Error: jest-haste-map: Haste module naming collision: Duplicate module name: react-native Paths: E:\react-native\.............\node_modules\react-native-twitter-signin\node_modules\react-native\package.json collides with E:\react-native\.............\heybuddy\node_modules\react-native\package.json

This error is caused by hasteImpl returning the same name for different files. at setModule (E:\react-native\.............\node_modules\jest-haste-map\build\index.js:551:17) at workerReply (E:\react-native\.............\node_modules\jest-haste-map\build\index.js:613:9) at process._tickCallback (internal/process/next_tick.js:68:7) (node:9460) UnhandledPromiseRejectionWarning: Unhandled promise rejection. This error originated either by throwing inside of an async function without a catch block, or by rejecting a promise which was not handled with .catch(). (rejection id: 3)

I tried to find the way to solve this error, but I can't find any solution.

2条回答
三岁会撩人
2楼-- · 2020-04-08 07:31

I had this problem and I created a backup of the source files and deleted everything. Deleting node_modules wasn't enough. After getting the files back and using npm install for the packages, it worked.

查看更多
劫难
3楼-- · 2020-04-08 07:31

I solved it by adding a new file named "rn-cli.config.js" in the project root folder, with the following contents.

const blacklist = require('metro-config/src/defaults/blacklist');
module.exports = {
    resolver: {
        blacklistRE: blacklist([
            /node_modules\/.*\/node_modules\/react-native\/.*/,
        ])
    },
};
查看更多
登录 后发表回答