27

I'm currently working on a project in React Native, yesterday it was working perfectly with no errors, and now all of a sudden I'm getting this error.

error Cannot find module 'metro-config/src/defaults/blacklist'
Require stack:
- /Users/sri/Downloads/cc_x/reactnativelcsapp/VitalitiApp/metro.config.js

I've tried soo many solutions, removing the node modules and installing it back, updating the modules, looking to change the backlist. I've checked my files and I can't find the blacklist file but I'm trying to fix it but honestly have no idea how to fix it. I was wondering if anyone would know what to do.

Sri Amin
  • 282
  • 1
  • 4
  • 9

4 Answers4

71

the blacklist file seems to be renamed as exclusionList

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

use this line instead in metro.config.js

vinay sandesh
  • 918
  • 9
  • 8
  • 1
    More information can be found here. https://github.com/aws-amplify/amplify-cli/issues/3295 – Sigex Aug 22 '21 at 21:01
3

In newer versions of metro-config the function is now called exclusionList. So change the blacklist reference with exclusionList in metro-config.js file which is located in the project root directory.

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

If still issue persists, then add metro-config as a dev dependency:

npm install -D metro-config
Codemaker2015
  • 12,190
  • 6
  • 97
  • 81
2

I had the same Issue as others. Changing it to

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

Fixed my issue.

I had to create metro.config.js and insert the following code since I was using AWS Amplify:

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

module.exports = {
    resolver: {
        blacklistRE: blacklist([/amplify\/#current-cloud-backend\/.*/]),
    },
    transformer: {
        getTransformOptions: async () => ({
            transform: {
                experimentalImportSupport: false,
                inlineRequires: false,
            },
        }),
    },
};
Micah Katz
  • 140
  • 5
0

I had the same error in myapp/node_modules/expo-yarn-workspaces/index.js From my require stack so I opened this file and found const blacklist = require('metro-config/src/defaults/blacklist'); into my app node modules.

So I changed it to

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

which fixed my problem

Dani3le_
  • 1,257
  • 1
  • 13
  • 22
SQ59
  • 1
  • 1