webpack 404 Not Found Not Found错误:无法解析“react-native/Libraries/Utilities/codegenNativeComponent”

cmssoen2  于 2023-03-23  发布在  Webpack
关注(0)|答案(1)|浏览(250)

我使用的是"react-native-web-linear-gradient": "^1.1.2",,它需要react-native-svg。我使用的是^13.8.0版本的svg包。
当我运行yarn storybook时,我得到以下错误:

ModuleNotFoundError: Module not found: Error: Can't resolve 'react-native/Libraries/NativeComponent/NativeComponentRegistry' in '<project-root>/node_modules/react-native-svg/lib/module/fabric'
    at <project-root>/node_modules/webpack/lib/Compilation.js:2016:28
ni65a41a

ni65a41a1#

我在Github this comment上的react-native-svg问题页面上发现,从9.8.5升级到9.8.6破坏了他们的Web构建:

I'm using react-native-svg in a project with react-native and react-native-web. When upgrading from 9.8.5 to 9.8.6 (or later) the web build starts breaking with the following error:

./node_modules/react-native-svg/lib/module/elements/Image.js
Attempted import error: 'requireNativeComponent' is not exported from 'react-native'.

It seems to me like the web compatibility layer is not used anymore, since it should not be loading that file for web at all.

所以我把我的svg包降级到9.8.5,现在它可以运行了。

"react-native-svg": "9.8.5",

相关问题