我将项目从0.51.0和16.0升级到React-Native 0.52.0和React 16.2,现在当我尝试使用XCode(或通过CLI)运行它时,我收到以下错误:
终端输出:
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
答案 0 :(得分:3)
请按照以下步骤操作:
sudo lsof -i :<Your port>
运行sudo kill -9 <PID>
将节点降级为版本8
再次运行该应用程序
答案 1 :(得分:-2)
React-Native不适用于Node v9.4。需要降级到Node v8。