0
votes

I'm using the out-of-the box react native framework to try to build a new app.

i used the following commands ind CMD (Windows 10).

node -v: v8.12.0

npm -v: 6.4.1

mkdir react-native-workspace

cd react-native-workspace

npm install -g create-react-native-app

create-react-native-app Exercise2

cd Exercise2

npm start

ERROR 12:42 (node:15564) UnhandledPromiseRejectionWarning: Error: jest-haste-map: @providesModule naming collision: Duplicate module name: my-new-project Paths: C:\Users\wp_99\Dokumenter\react-native-workspace\Exercise2\package.json collides with C:\Users\wp_99\Documents\react-native-workspace\Exercise2\package.json

This error is caused by a @providesModule declaration with the same name across two different files. at setModule (C:\Users\wp_99\Documents\react-native-workspace\Exercise2\node_modules\metro\node_modules\jest-haste-map\build\index.js:462:17) at workerReply (C:\Users\wp_99\Documents\react-native-workspace\Exercise2\node_modules\metro\node_modules\jest-haste-map\build\index.js:512:9) at at process._tickCallback (internal/process/next_tick.js:189:7) ERROR 12:42 (node:15564) 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:15564) [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.

2

2 Answers

0
votes

It's a bug in the metro-bundler. You should create rn-cli.config.js and add this configuration to it:
For react-native>=0.57

const blacklist = require('metro-config/src/defaults/blacklist');

module.exports = {
  resolver:{
    blacklistRE: blacklist([
      /nodejs-assets\/.*/,
      /android\/.*/,
      /ios\/.*/
    ])
  },
};  

react-native < 0.57

const blacklist = require('metro/src/blacklist');

module.exports = {
  getBlacklistRE: function() {
    return blacklist([
      /nodejs-assets\/.*/,
      /android\/.*/,
      /ios\/.*/
    ]);
  },
};  

You can read more here.

0
votes

I've added the following to rn-cli.config.js

const blacklist = require('metro-config/src/defaults/blacklist');

module.exports = {
    resolver: {
        blacklistRE: blacklist([
            /node_modules\/.*\/node_modules\/react-native\/.*/,
        ])
    },
};