我开始通过本教程学习 ReactNative:https://openclassrooms.com/fr/courses/4902061-developpez-une-application-mobile-react-native
一切正常,但是当我们将我们的应用程序转换为原生应用程序时,我无法在 android 上编译它。
当 react-native run-android
时我总是有这个错误:
error: bundling failed: Invariant Violation: invalid asset resolution
at invariant (C:\laragon\www\React\SampleReactNativeProject\node_modules\invariant\invariant.js:40:15)
at ModuleResolver._getFileResolvedModule (C:\laragon\www\React\SampleReactNativeProject\node_modules\metro\src\node-haste\DependencyGraph\ModuleResolution.js:224:9)
at ModuleResolver.resolveDependency (C:\laragon\www\React\SampleReactNativeProject\node_modules\metro\src\node-haste\DependencyGraph\ModuleResolution.js:159:19)
at ResolutionRequest.resolveDependency (C:\laragon\www\React\SampleReactNativeProject\node_modules\metro\src\node-haste\DependencyGraph\ResolutionRequest.js:52:18)
at DependencyGraph.resolveDependency (C:\laragon\www\React\SampleReactNativeProject\node_modules\metro\src\node-haste\DependencyGraph.js:283:16)
at Object.resolve (C:\laragon\www\React\SampleReactNativeProject\node_modules\metro\src\lib\transformHelpers.js:261:42)
at dependencies.map.result (C:\laragon\www\React\SampleReactNativeProject\node_modules\metro\src\DeltaBundler\traverseDependencies.js:399:31)
at Array.map (<anonymous>)
at resolveDependencies (C:\laragon\www\React\SampleReactNativeProject\node_modules\metro\src\DeltaBundler\traverseDependencies.js:396:18)
at C:\laragon\www\React\SampleReactNativeProject\node_modules\metro\src\DeltaBundler\traverseDependencies.js:269:33
然后把这个放在手机上:
这是我的代码:https://gitlab.com/baltus.remi/moviesandme
我已经尝试重新安装所有环境等等。 如果我运行 android un basic react-native 应用程序,它的工作就像一个魅力......
感谢您的帮助!
最佳答案
尝试删除应用程序。然后清理项目运行 cd android && ./gradlew clean
然后回到根目录cd..
然后再次进行调试构建 react-native run-android 或脚本中的任何命令
大多数情况下,如果添加了新包,这些步骤是必需的。
关于android - Metro Bundler 内部遇到内部错误,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/55223851/