React Native 找不到模块'txtxtxtxtxtxtxtxtxtxtxtxtxtxtxtxtxtxtxtxtxtxtxtxtxtxtxtxtxtxtxtxtxtxtxtxtxtxtxtxtxtxtxtxtxtxtxtxtxtxtxtxtxtxtxtxtxtxtxtxtxtxtxtxtxtxtxtxtxtxtxtxtxtxtxtxtxtxtxtxtxtxtxtxtxtxtxtxtxtxtxtxtxtxtxtxtxt

kadbb459  于 2022-11-17  发布在  React
关注(0)|答案(4)|浏览(156)

升级到RN 0.59.4并成功构建后,用户可能会在Metro Bundler中遇到以下错误:
react native Cannot find module 'metro/src/reactNative Transformer

ycggw6v2

ycggw6v21#

我认为最新RN升级包中的metro版本有问题。我只是在本地安装了dev metro npm install --save-dev metro,版本是0.51.1,这对我来说是有效的。
参考:https://github.com/facebook/metro/issues/293#issuecomment-452779809

drkbr07n

drkbr07n2#

确保您至少:
"metro-react-native-babel-preset": "0.53.1"
在package.json文件中的开发依赖项中

fdbelqdn

fdbelqdn3#

我通过删除node_modules文件夹和package-lock.json文件,然后再次运行npm install解决了该问题

a1o7rhls

a1o7rhls4#

由于已升级ReactNative,因此必须关闭运行Metro终端,然后重新运行npx react-native start

相关问题