taro 编译为 react-native 无法运行,使用 react-native start 编译不通过



  • react-native start
    ┌──────────────────────────────────────────────────────────────────────────────┐
    │ │
    │ Running Metro Bundler on port 8081. │
    │ │
    │ Keep Metro running while developing on any JS projects. Feel free to │
    │ close this tab and run your own Metro instance if you prefer. │
    │ │
    https://github.com/facebook/react-native
    │ │
    └──────────────────────────────────────────────────────────────────────────────┘

    Looking for JS files in
    D:\local\一些测试\myApp

    Loading dependency graph, done.
    error: bundling failed: Error: Unable to resolve module warnOnce from node_modules\react-native\Libraries\react-native\react-native-implementation.js: warnOnce could not be found within the project.

    If you are sure the module exists, try these steps:

    1. Clear watchman watches: watchman watch-del-all
    2. Delete node_modules: rm -rf node_modules and run yarn install
    3. Reset Metro's cache: yarn start --reset-cache
    4. Remove the cache: rm -rf /tmp/metro-*
      at ModuleResolver.resolveDependency (C:\Users\xiao\AppData\Roaming\npm\node_modules\react-native\node_modules\metro\src\node-haste\DependencyGraph\ModuleResolution.js:186:15)
      at ResolutionRequest.resolveDependency (C:\Users\xiao\AppData\Roaming\npm\node_modules\react-native\node_modules\metro\src\node-haste\DependencyGraph\ResolutionRequest.js:52:18)
      at DependencyGraph.resolveDependency (C:\Users\xiao\AppData\Roaming\npm\node_modules\react-native\node_modules\metro\src\node-haste\DependencyGraph.js:282:16)
      at Object.resolve (C:\Users\xiao\AppData\Roaming\npm\node_modules\react-native\node_modules\metro\src\lib\transformHelpers.js:267:42)
      at C:\Users\xiao\AppData\Roaming\npm\node_modules\react-native\node_modules\metro\src\DeltaBundler\traverseDependencies.js:426:31
      at Array.map (<anonymous>)
      at resolveDependencies (C:\Users\xiao\AppData\Roaming\npm\node_modules\react-native\node_modules\metro\src\DeltaBundler\traverseDependencies.js:423:18)
      at C:\Users\xiao\AppData\Roaming\npm\node_modules\react-native\node_modules\metro\src\DeltaBundler\traverseDependencies.js:275:33
      at Generator.next (<anonymous>)
      at asyncGeneratorStep (C:\Users\xiao\AppData\Roaming\npm\node_modules\react-native\node_modules\metro\src\DeltaBundler\traverseDependencies.js:87:24)
      BUNDLE [ios, dev] rn_temp/index.js ░░░░░░░░░░░░░░░░ 1.2% (9/82), failed.

    ::ffff:127.0.0.1 - - [11/Jan/2020:18:40:15 +0000] "GET /rn_temp/index.bundle?platform=ios&dev=true HTTP/1.1" 500 - "-" "Mozilla/5.0 (Windows NT 10.0; Win64; x64) AppleWebKit/537.36 (KHTML, like Gecko) Chrome/79.0.3945.117 Safari/537.36"



  • 重新安装 react-native 依赖。

    然后关闭自动打开的 metro server 窗口。

    在项目根目录下运行:node ./node_modules/react-native/local-cli/cli.js start --reset-cache 手动启动。

    这样会清除缓存。


登录后回复