2
votes

I just installed react native and created a fresh project, But when I'm running it by using react-native run-android command it is giving error. I didn't changed anything in any file the project is just created.

Here are the error and screenshot of it.

screenshot of error

Error

The development server returned response error code: 500

URL: http://10.0.2.2:8081/index.delta?platform=android&dev=true&minify=false

Body:

{"originModulePath":"C:\project\test\App.js","targetModuleName":"./../../react-transform-hmr/lib/index.js","message":"Unable to resolve module './../../react-transform-hmr/lib/index.js' from 'C:\project\test\App.js': The module './../../react-transform-hmr/lib/index.js' could not be found from 'C:\project\test\App.js'. Indeed, none of these files exist:\n * 'C:\react-transform-hmr\lib\index.js(.native||.android.js|.native.js|.js|.android.json|.native.json|.json|.android.ts|.native.ts|.ts|.android.tsx|.native.tsx|.tsx)'\n * 'C:\react-transform-hmr\lib\index.js\index(.native||.android.js|.native.js|.js|.android.json|.native.json|.json|.android.ts|.native.ts|.ts|.android.tsx|.native.tsx|.tsx)'","errors":[{"description":"Unable to resolve module './../../react-transform-hmr/lib/index.js' from 'C:\project\test\App.js': The module './../../react-transform-hmr/lib/index.js' could not be found from 'C:\project\test\App.js'. Indeed, none of these files exist:\n * 'C:\react-transform-hmr\lib\index.js(.native||.android.js|.native.js|.js|.android.json|.native.json|.json|.android.ts|.native.ts|.ts|.android.tsx|.native.tsx|.tsx)'\n * 'C:\react-transform-hmr\lib\index.js\index(.native||.android.js|.native.js|.js|.android.json|.native.json|.json|.android.ts|.native.ts|.ts|.android.tsx|.native.tsx|.tsx)'"}],"name":"Error","stack":"Error: Unable to resolve module './../../react-transform-hmr/lib/index.js' from 'C:\project\test\App.js': The module './../../react-transform-hmr/lib/index.js' could not be found from 'C:\project\test\App.js'. Indeed, none of these files exist:\n * 'C:\react-transform-hmr\lib\index.js(.native||.android.js|.native.js|.js|.android.json|.native.json|.json|.android.ts|.native.ts|.ts|.android.tsx|.native.tsx|.tsx)'\n * 'C:\react-transform-hmr\lib\index.js\index(.native||.android.js|.native.js|.js|.android.json|.native.json|.json|.android.ts|.native.ts|.ts|.android.tsx|.native.tsx|.tsx)'\n at ModuleResolver.resolveDependency (C:\project\test\node_modules\metro\src\node-haste\DependencyGraph\ModuleResolution.js:209:697)\n at ResolutionRequest.resolveDependency (C:\project\test\node_modules\metro\src\node-haste\DependencyGraph\ResolutionRequest.js:83:16)\n at DependencyGraph.resolveDependency (C:\project\test\node_modules\metro\src\node-haste\DependencyGraph.js:222:485)\n at Object.resolve (C:\project\test\node_modules\metro\src\lib\transformHelpers.js:149:25)\n at dependencies.map.result (C:\project\test\node_modules\metro\src\DeltaBundler\traverseDependencies.js:316:29)\n at Array.map ()\n at resolveDependencies (C:\project\test\node_modules\metro\src\DeltaBundler\traverseDependencies.js:312:16)\n at C:\project\test\node_modules\metro\src\DeltaBundler\traverseDependencies.js:169:33\n at Generator.next ()\n at step (C:\project\test\node_modules\metro\src\DeltaBundler\traverseDependencies.js:271:307)"} processBundleResult BundleDownloader.java:296 access$200 BundleDownloader.java:37 onResponse BundleDownloader.java:174 execute RealCall.java:153 run NamedRunnable.java:32 runWorker ThreadPoolExecutor.java:1113 run ThreadPoolExecutor.java:588 run Thread.java:818

Please help me get out of this...

2

2 Answers

6
votes

Try these steps:

1- Clear the cache using:

rm -rf $TMPDIR/react-*; rm -rf $TMPDIR/haste-*; rm -rf $TMPDIR/metro-*;

2 - If you are using the watchman, remove all watches and associated triggers with:

watchman watch-del-all

3 - Restart the Metro Bundler from the project folder

react-native start  --reset-cache 

4 - Run react-native run-android

0
votes

I faced this problem before try this solutions,

1- Restart metro bundler with npm start

2- Restart project with different port react-native run-android --port=8088

Because sometimes default port 8081 may used by another app.