首页 > 解决方案 > 在 react-native 项目中找不到 metro-config node_modules

问题描述

我在我的项目中提供“react-native start”命令,它给了我以下错误。

无效的正则表达式:/(。\__fixtures__\。 |node_modules[\]react[\]dist[\]。|website\node_modules\。 |heapCapture\bundle.js|。\__tests__\。 )$/:未终止的字符类

我在这里找到了上述问题的解决方案。

但问题是当我试图导航"node_modules\metro-config\src\defaults\blacklist.js"到此路径时,没有名为"metro-config".

我确实删除了 node_modules 并再次重新安装它们,但问题仍然相同。

标签: androidnode.jsreactjsreact-nativenode-modules

解决方案


您也可以在此位置找到blacklist.js文件,node_modules/metro/src/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__\/.*/
];

我昨晚才修好的。


推荐阅读