我使用命令提示符和react-native命令创建了一个新的react-native项目。当我尝试使用Android Studio模拟器打开项目时,出现以下错误:
The development server returned response error code: 500
URL: http://10.0.2.2:8081/index.delta?platform=android&dev=true&minify=false
Body:
<!DOCTYPE html>
<html lang="en">
<head>
<meta charset="utf-8">
<title>Error</title>
</head>
<body>
<pre>Error: Unable to resolve module ./index from
D:\ReactNative\myreactdemo\node_modules\react-native\scripts/.: The module ./index could not be found from
D:\ReactNative\myreactdemo\node_modules\react-native\scripts/.. Indeed, none of these files exist:<br> * D:\ReactNative\myreactdemo\node_modules\react-native\scripts\index(.native||.android.js|.native.js|.js|.android.json|.native.json|.json|.android.ts|.native.ts|.ts|.android.tsx|.native.tsx|.tsx)`<br> *D:\ReactNative\myreactdemo\node_modules\react-native\scripts\index\index(.native||.android.js|.native.js|.js|.android.json|.native.json|.json|.android.ts|.native.ts|.ts|.android.tsx|.native.tsx|.tsx)`<br> at ModuleResolver.resolveDependency (D:\ReactNative\myreactdemo\node_modules\metro\src\node-haste\DependencyGraph\ModuleResolution.js:163:15)<br> at ResolutionRequest.resolveDependency (D:\ReactNative\myreactdemo\node_modules\metro\src\node-haste\DependencyGraph\ResolutionRequest.js:52:18)<br> at DependencyGraph.resolveDependency (D:\ReactNative\myreactdemo\node_modules\metro\src\node-haste\DependencyGraph.js:283:16)<br> at D:\ReactNative\myreactdemo\node_modules\metro\src\lib\transformHelpers.js:261:42<br> at Server.<anonymous> (D:\ReactNative\myreactdemo\node_modules\metro\src\Server.js:1038:41)<br> at Generator.next (<anonymous>)<br> at asyncGeneratorStep (D:\ReactNative\myreactdemo\node_modules\metro\src\Server.js:99:24)<br> at _next (D:\ReactNative\myreactdemo\node_modules\metro\src\Server.js:119:9)</pre>
</body>
</html>
processBundleResult
BundleDownloader.java:296
access$200
BundleDownloader.java:37
onResponse
BundleDownloader.java:174
execute
RealCall.java:206
run
NamedRunnable.java:32
runWorker
ThreadPoolExecutor.java:1167
run
ThreadPoolExecutor.java:641
run
Thread.java:764
答案 0 :(得分:1)
修改
\ node_modules @ react-native-community \ cli \ build \ commands \ runAndroid \ runAndroid.js并已替换 cwd:scriptsDir与cwd:process.cwd()
答案 1 :(得分:0)
react-native start --reset-cache
在一个终端中并保持打开状态
react-native run-android
在另一个终端
答案 2 :(得分:0)
此错误是由nodeJS服务器引起的。其原因是因为语法错误。您能否在发生错误的地方共享代码(./index文件)。