一、问题:
新建一个工程后,在执行react-native start 后访问:http://localhost:8081/index.android.bundle?platform=android
报错:
Error: Unable to resolve module `./index.android` from `D:DevelopToolsReactNativeProjectsFirstProject/.`: The module `./index.android` could not be found from `D:DevelopToolsReactNativeProjectsFirstProject/.`. Indeed, none of these files exist: * `D:DevelopToolsReactNativeProjectsFirstProjectindex.android(.native||.android.js|.native.js|.js|.android.json|.native.json|.json|.android.ts|.native.ts|.ts|.android.tsx|.native.tsx|.tsx)` * `D:DevelopToolsReactNativeProjectsFirstProjectindex.androidindex(.native||.android.js|.native.js|.js|.android.json|.native.json|.json|.android.ts|.native.ts|.ts|.android.tsx|.native.tsx|.tsx)` at ModuleResolver.resolveDependency (D:DevelopToolsReactNativeProjectsFirstProject ode_modulesmetrosrc ode-hasteDependencyGraphModuleResolution.js:163:15) at ResolutionRequest.resolveDependency (D:DevelopToolsReactNativeProjectsFirstProject ode_modulesmetrosrc ode-hasteDependencyGraphResolutionRequest.js:52:18) at DependencyGraph.resolveDependency (D:DevelopToolsReactNativeProjectsFirstProject ode_modulesmetrosrc ode-hasteDependencyGraph.js:283:16) at D:DevelopToolsReactNativeProjectsFirstProject ode_modulesmetrosrclib ransformHelpers.js:264:42 at Server.<anonymous> (D:DevelopToolsReactNativeProjectsFirstProject ode_modulesmetrosrcServer.js:1049:41) at Generator.next (<anonymous>) at asyncGeneratorStep (D:DevelopToolsReactNativeProjectsFirstProject ode_modulesmetrosrcServer.js:99:24) at _next (D:DevelopToolsReactNativeProjectsFirstProject ode_modulesmetrosrcServer.js:119:9)
二、解决:
是react native版本更新的一些变动。原来工程中会创建:index.ios.js 和index.android.js,现在只会创建index.js。一个简单的规避方法,就是copy 一份index.js 文件命名为index.android.js即可。
##########################################################################################
扫码加群,共同探讨,共同进步!