我将项目从0.51.0和16.0升级到React-Native 0.52.0和React 16.2,现在当我尝试使用XCode(或通过CLI)运行它时,出现以下错误:

reactjs - React-Native 0.52 : Metro Bundler has encountered an internal error-LMLPHP

终端输出:

2018-01-20 06:19:16.972 [info][tid:main][RCTCxxBridge.mm:210] Initializing <RCTCxxBridge: 0x6000001c2850> (parent: <RCTBridge: 0x6040000c7620>, executor: (null))
2018-01-20 06:19:16.975378-0800 LevelStory[67373:2037856] Initializing <RCTCxxBridge: 0x6000001c2850> (parent: <RCTBridge: 0x6040000c7620>, executor: (null))
2018-01-20 06:19:17.158 [warn][tid:main][RCTBridge.m:120] Class RCTCxxModule was not exported. Did you forget to use RCT_EXPORT_MODULE()?
2018-01-20 06:19:17.158401-0800 LevelStory[67373:2037856] Class RCTCxxModule was not exported. Did you forget to use RCT_EXPORT_MODULE()?
2018-01-20 06:19:17.215 [warn][tid:main][RCTModuleData.mm:69] Module RCTImageLoader requires main queue setup since it overrides `init` but doesn't implement `requiresMainQueueSetup`. In a future release React Native will default to initializing all native modules on a background thread unless explicitly opted-out of.
2018-01-20 06:19:17.215060-0800 LevelStory[67373:2037856] Module RCTImageLoader requires main queue setup since it overrides `init` but doesn't implement `requiresMainQueueSetup`. In a future release React Native will default to initializing all native modules on a background thread unless explicitly opted-out of.
2018-01-20 06:19:17.231 [info][tid:main][RCTRootView.m:302] Running application LevelStory ({
    initialProps =     {
    };
    rootTag = 1;
})
2018-01-20 06:19:17.231250-0800 LevelStory[67373:2037856] Running application LevelStory ({
    initialProps =     {
    };
    rootTag = 1;
})
2018-01-20 06:19:17.345 [error][tid:NSOperationQueue 0x6040000355a0 (QOS: UNSPECIFIED)][RCTCxxBridge.mm:419] Failed to load bundle(http://localhost:8081/index.bundle?platform=ios&dev=true&minify=false) with error:(Metro Bundler has encountered an internal error, please check your terminal error output for more details (null))
2018-01-20 06:19:17.346054-0800 LevelStory[67373:2038114] Failed to load bundle(http://localhost:8081/index.bundle?platform=ios&dev=true&minify=false) with error:(Metro Bundler has encountered an internal error, please check your terminal error output for more details (null))

我试着删除并重新安装node_modules文件夹,清理缓存,清理看守,将库重新链接无济于事。我对使用react-native init创建的全新项目也遇到了同样的问题。
Environment:
  OS: macOS Sierra 10.12.6
  Node: 9.4.0
  Yarn: 1.3.2
  npm: 5.6.0
  Watchman: 4.9.0
  Xcode: Xcode 9.2 Build version 9C40b
  Android Studio: 2.3 AI-162.3871768

Packages: (wanted => installed)
  react: 16.2.0 => 16.2.0
  react-native: 0.52.0 => 0.52.0

最佳答案

按着这些次序:

  • sudo lsof -i :<Your port>
  • 运行sudo kill -9 <PID>
  • 将节点降级到版本8
  • 再次运行应用程序
  • 关于reactjs - React-Native 0.52 : Metro Bundler has encountered an internal error,我们在Stack Overflow上找到一个类似的问题:https://stackoverflow.com/questions/48357335/

    10-15 23:19