React Native 错误:正则表达式无效:Metro Bundler进程已退出,代码为1

yshpjwxd  于 2022-12-14  发布在  React
关注(0)|答案(3)|浏览(170)

每个项目都工作得很好,直到这个错误。我不知道这是由于节点升级;我尝试将节点从最新版本降级到稳定版本,但没有任何效果!!我使用 yarn start 运行我的react原生项目

Err: error Invalid regular expression: /(.*\\__fixtures__\\.*|node_modules[\\\]react[\\\]dist[\\\].*|website\\node_modules\\.*|heapCapture\\bundle\.js|.*\\__tests__\\.*)$/: Unterminated character class. Run CLI with --verbose flag for more details.

Metro Bundler process exited with code 1
Set EXPO_DEBUG=true in your env to view the stack trace.
8dtrkrch

8dtrkrch1#

转到node_modules -〉metro-config -〉源代码-〉默认值-〉blacklist.js
查找此数组:

var sharedBlacklist = [
  /node_modules[/\\]react[/\\]dist[/\\].*/,
  /website\/node_modules\/.*/,
  /heapCapture\/bundle\.js/,
  /.*\/__tests__\
  ];

用这个代替

var sharedBlacklist = [
  /node_modules[\/\\]react[\/\\]dist[\/\\].*/,
  /website\/node_modules\/.*/,
  /heapCapture\/bundle\.js/,
  /.*\/__tests__\
  ];
x4shl7ld

x4shl7ld2#

自从上一个答案不起作用之后,事情似乎发生了变化。打开文件PROJECT_NAME\node_modules\metro-config\src\defaults\blacklist.js,将当前的var sharedBlacklist替换为:
var sharedBlacklist = [/node_modules[\/\\]react[\/\\]dist[\/\\].*/,/website\/node_modules\/.*/,/heapCapture\/bundle\.js/,/.*\/__tests__\/.*/];

m2xkgtsf

m2xkgtsf3#

转到以下文件node_modules〉metro-config〉源代码〉默认值〉blacklist.js
及找到了

var sharedBlacklist = [
  /node_modules[/\\]react[/\\]dist[/\\].*/,
  /website\/node_modules\/.*/,
  /heapCapture\/bundle\.js/,
  /.*\/__tests__\/.*/
];

并更新为

var sharedBlacklist = [
  /node_modules[\/\\]react[\/\\]dist[\/\\].*/,
  /website\/node_modules\/.*/,
  /heapCapture\/bundle\.js/,
  /.*\/__tests__\/.*/
];

相关问题