【问题标题】:How to configure with create-react-native-app metro bundler如何使用 create-react-native-app Metro 捆绑器进行配置
【发布时间】:2021-01-15 20:58:45
【问题描述】:

我是 react-native 的新手,这个社区很棒。

但我在使用 npx create-react-native-app 配置 https://github.com/terrylinla/react-native-sketch-canvas 时遇到问题。

到目前为止我所做的只是编辑metro.config.js

const extraNodeModules = {
  '@terrylinla/react-native-sketch-canvas': './node_modules/@terrylinla\react-native-sketch-canvas/'
}

const resolverMainFields = ['browser','main'];

module.exports = {
  resolver: {
    extraNodeModules,
    resolverMainFields
  },
  transformer: {
    getTransformOptions: async () => ({
      transform: {
        experimentalImportSupport: false,
        inlineRequires: false,
      },
    }),
  },
};

然后 cmd react-native run-android 它会正确捆绑,但它永远不会加载到模拟器上:

这就是它在 shell 中所说的:


info Running jetifier to migrate libraries to AndroidX. You can disable it using "--no-jetifier" flag.
(node:8712) Warning: Accessing non-existent property 'padLevels' of module exports inside circular dependency
(Use node --trace-warnings ... to show where the warning was created)
Jetifier found 987 file(s) to forward-jetify. Using 4 workers...
info Starting JS server...
info Launching emulator...
info Successfully launched emulator.
info Installing the app...

Configure project :terrylinla_react-native-sketch-canvas
WARNING: Configuration 'provided' is obsolete and has been replaced with 'compileOnly'.
It will be removed soon. For more information see: http://d.android.com/r/tools/update-dependency-configurations.html

Task :app:stripDebugDebugSymbols UP-TO-DATE
Compatible side by side NDK version was not found.
<============-> 99% EXECUTING [10m 30s]
IDLE
IDLE
:app:installDebug
IDLE

【问题讨论】:

    标签: react-native metro-bundler


    【解决方案1】:

    所以我只是让 Metro 来正确捆绑我的 js 文件。我发现这与 react-native android gradle 有关,这非常令人困惑。但是我刚刚重新启动了计算机并运行了相同的命令。这样就解决了。

    这些 stackoverflow 答案之前对我有用,可以让我的构建工作:

    Stuck on info starting JS server

    React-native run-android stuck at 99% appDebug

    我希望这对使用 create-react-native-appmetro-bundler 的人有所帮助

    【讨论】:

      猜你喜欢
      • 1970-01-01
      • 1970-01-01
      • 2020-01-03
      • 1970-01-01
      • 2018-02-07
      • 2019-03-10
      • 2016-12-12
      • 2018-11-07
      • 2017-09-12
      相关资源
      最近更新 更多