React-native: Question: run-android error, Unable to resolve module `./index`

Created on 23 Mar 2019  路  2Comments  路  Source: facebook/react-native

After rm -rf node_modules && npm i, the problem remains the same:

Looking for JS files in
D:\Projects\Temp\TestApp\node_modules\react-native\scripts

Loading dependency graph, done.
Error: Unable to resolve module ./index from D:\Projects\Temp\TestApp\node_mo dules\react-native\scripts/.: The module ./index could not be found from D:\ Projects\Temp\TestApp\node_modules\react-native\scripts/.. Indeed, none of thes
e files exist:

  • D:\Projects\Temp\TestApp\node_modules\react-native\scripts\index(.native||. android.js|.native.js|.js|.android.json|.native.json|.json|.android.ts|.native.t s|.ts|.android.tsx|.native.tsx|.tsx)
  • D:\Projects\Temp\TestApp\node_modules\react-native\scripts\index\index(.nat ive||.android.js|.native.js|.js|.android.json|.native.json|.json|.android.ts|.na tive.ts|.ts|.android.tsx|.native.tsx|.tsx)
    at ModuleResolver.resolveDependency (D:\Projects\Temp\TestApp\node_modules\m
    etro\src\node-haste\DependencyGraph\ModuleResolution.js:163:15)
    at ResolutionRequest.resolveDependency (D:\Projects\Temp\TestApp\node_module
    s\metro\src\node-haste\DependencyGraph\ResolutionRequest.js:52:18)
    at DependencyGraph.resolveDependency (D:\Projects\Temp\TestApp\node_modules\
    metro\src\node-haste\DependencyGraph.js:283:16)
    at D:\Projects\Temp\TestApp\node_modules\metro\srclibtransformHelpers.js:2
    61:42
    at Server. (D:\Projects\Temp\TestApp\node_modules\metro\src\Serve
    r.js:1038:41)
    at Generator.next ()
    at asyncGeneratorStep (D:\Projects\Temp\TestApp\node_modules\metro\src\Serve
    r.js:99:24)
    at _next (D:\Projects\Temp\TestApp\node_modules\metro\src\Server.js:119:9)
    ::ffff:127.0.0.1 - - [23/Mar/2019:15:19:02 +0000] "GET /index.delta?platform=and
    roid&dev=true&minify=false HTTP/1.1" 500 - "-" "okhttp/3.12.1"

package.json:

{
"name": "TestApp",
"version": "0.0.1",
"private": true,
"scripts": {
"start": "node node_modules/react-native/local-cli/cli.js start",
"test": "jest",
"lint": "eslint ."
},
"dependencies": {
"react": "16.8.3",
"react-native": "0.59.1"
},
"devDependencies": {
"@babel/core": "^7.4.0",
"@babel/runtime": "^7.4.2",
"@react-native-community/eslint-config": "^0.0.3",
"babel-jest": "^24.5.0",
"eslint": "^5.15.3",
"jest": "^24.5.0",
"metro-react-native-babel-preset": "^0.53.1",
"react-test-renderer": "16.8.3"
},
"jest": {
"preset": "react-native"
}
}

Ran Commands Locked Question

Most helpful comment

I'm getting this same error for react-native run-ios on a Mac. It's a brand new, empty project, just created with the latest react-native cli (i.e. _not_ expo).

But the index.js file _is_ there in the root of the project, right where it should be.

I don't know why the react-native-bot has closed this as "a question". It's quite obviously an error report.

Update
I managed to get it working by following advice comment on #23908. I ran:

react-native start -- --reset-cache

in one command line window, followed by:

react-native run-ios

in _separate_ command line window.

All 2 comments

We are using GitHub issues exclusively to track bugs in React Native. GitHub may not be the ideal place to ask a question, but you can try asking over on Stack Overflow, or on Reactiflux. You may also use discuss.reactjs.org/ to discuss best practices.

I'm getting this same error for react-native run-ios on a Mac. It's a brand new, empty project, just created with the latest react-native cli (i.e. _not_ expo).

But the index.js file _is_ there in the root of the project, right where it should be.

I don't know why the react-native-bot has closed this as "a question". It's quite obviously an error report.

Update
I managed to get it working by following advice comment on #23908. I ran:

react-native start -- --reset-cache

in one command line window, followed by:

react-native run-ios

in _separate_ command line window.

Was this page helpful?
0 / 5 - 0 ratings