Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

error Cannot find module 'metro-config/src/defaults/blacklist' #31215

Closed
Junhano opened this issue Mar 23, 2021 · 7 comments
Closed

error Cannot find module 'metro-config/src/defaults/blacklist' #31215

Junhano opened this issue Mar 23, 2021 · 7 comments
Labels
Needs: Triage 🔍 Resolution: Locked This issue was locked by the bot.

Comments

@Junhano
Copy link

Junhano commented Mar 23, 2021

Don't know what happened. I upgrade my React Native from 0.63.4 to 0.64, upgrade Cocopods and this errors appear when I try to run my app. Before the upgrades everything works fine

My metro.config.js file

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

module.exports = {
  resolver: {
    blacklistRE: blacklist([/#current-cloud-backend\/.*/]),
  },
  transformer: {
    getTransformOptions: async () => ({
      transform: {
        experimentalImportSupport: false,
        inlineRequires: false,
      },
    }),
  },
};
@efstathiosntonas
Copy link

I think blacklist naming has changed a bit, please visit the blacklist source code and check what has changed.

@efstathiosntonas
Copy link

@Junhano check this: https://stackoverflow.com/a/41963217/2195000

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

// exclusionList is a function that takes an array of regexes and combines
// them with the default exclusions to return a single regex.

module.exports = {
  resolver: {
    blacklistRE: exclusionList([/dist\/.*/])
  }
};

@xxsnakerxx
Copy link

@Junhano Junhano closed this as completed Mar 27, 2021
@Junhano
Copy link
Author

Junhano commented Mar 27, 2021

Fixed

@ferdicus
Copy link
Contributor

@Junhano, I'm happy that you got your issue resolved - would you kindly post the solution to your problem, so other people stumbling over the issue can actually jump straight to the resolution?
Thanks

@iJimmyWei
Copy link

iJimmyWei commented Jun 1, 2021

It looks like blacklist was renamed to exclusionList for inclusive language reasons in .64 (facebook/metro@3e2d911)

For me excluding dist with efstathiosntonas's example was too destructive. I adapted it and this worked out for me:

metro.config.js

const path = require("path");
const exclusionList = require('metro-config/src/defaults/exclusionList');
const escape = require("escape-string-regexp");
const pak = require("../package.json");

const root = path.resolve(__dirname, "..");

const modules = Object.keys({
    ...pak.peerDependencies,
});

module.exports = {
    resolver: {
        blacklistRE: exclusionList(
            modules.map(
                (m) =>
                    new RegExp(`^${escape(path.join(root, "node_modules", m))}\\/.*$`)
            ))
    },
};

@ferdicus
Copy link
Contributor

ferdicus commented Jun 2, 2021

Yep, just a name change indeed:

// exclusionList is a function that takes an array of regexes and combines
// them with the default exclusions to return a single regex.
const exclusionList = require('metro-config/src/defaults/exclusionList');

blacklist => exclusionList

@facebook facebook locked as resolved and limited conversation to collaborators Mar 27, 2022
@react-native-bot react-native-bot added the Resolution: Locked This issue was locked by the bot. label Mar 27, 2022
Sign up for free to subscribe to this conversation on GitHub. Already have an account? Sign in.
Labels
Needs: Triage 🔍 Resolution: Locked This issue was locked by the bot.
Projects
None yet
Development

No branches or pull requests

6 participants