[英]React Native Error Cannot find module 'metro-config/src/defaults/blacklist'
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.我目前正在使用 React Native 开发一个项目,昨天它运行完美,没有任何错误,现在我突然遇到了这个错误。
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.我想知道是否有人会知道该怎么做。
the blacklist file seems to be renamed as exclusionList黑名单文件似乎被重命名为 excludeList
const blacklist = require('metro-config/src/defaults/exclusionList');
use this line instead in metro.config.js在metro.config.js 中使用这一行
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:我必须创建metro.config.js
并插入以下代码,因为我使用的是 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,
},
}),
},
};
In newer versions of metro-config
the function is now called exclusionList
.在新版本的metro-config
中,该函数现在称为exclusionList
。 So change the blacklist
reference with exclusionList
in metro-config.js
file which is located in the project root directory.因此,使用项目根目录中的metro-config.js
文件中的exclusionList
更改blacklist
引用。
const exclusionList = require('metro-config/src/defaults/exclusionList');
If still issue persists, then add metro-config
as a dev dependency:如果问题仍然存在,则添加metro-config
作为开发依赖项:
npm install -D metro-config
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');
我在myapp/node_modules/expo-yarn-workspaces/index.js中遇到了同样的错误来自我的 require 堆栈所以我打开这个文件并找到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这解决了我的问题
声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.