无法解析模块`。/ index`

时间:2019-03-25 02:45:34

标签: react-native

过去几天,我的代码中一直无法解析模块索引,并且找到了临时解决方案,但找不到永久性修复程序。

过去几天我一直收到此错误,并在运行“ npm start---reset-cache”时找到了一个临时解决方案,但是每当我再次运行“ react-native run-android”时,出现相同的错误。这是错误。

为什么会出现此错误?如何在不使用我的临时解决方案的情况下解决该错误?

Error: Unable to resolve module `./index` from `c:\reactnative\a\node_modules\react-native\scripts/.`: The module `./index` could not be found from `c:\reactnative\a\node_modules\react-native\scripts/.`. Indeed, none of these files exist:
  * `c:\reactnative\a\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)`
  * `c:\reactnative\a\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)`
    at ModuleResolver.resolveDependency (c:\reactnative\a\node_modules\metro\src\node-haste\DependencyGraph\ModuleResolution.js:163:15)
    at ResolutionRequest.resolveDependency (c:\reactnative\a\node_modules\metro\src\node-haste\DependencyGraph\ResolutionRequest.js:52:18)
    at DependencyGraph.resolveDependency (c:\reactnative\a\node_modules\metro\src\node-haste\DependencyGraph.js:283:16)
    at c:\reactnative\a\node_modules\metro\src\lib\transformHelpers.js:261:42
    at Server.<anonymous> (c:\reactnative\a\node_modules\metro\src\Server.js:1038:41)
    at Generator.next (<anonymous>)
    at asyncGeneratorStep (c:\reactnative\a\node_modules\metro\src\Server.js:99:24)
    at _next (c:\reactnative\a\node_modules\metro\src\Server.js:119:9)
::ffff:127.0.0.1 - - [25/Mar/2019:02:18:03 +0000] "GET /index.delta?platform=android&dev=true&minify=false HTTP/1.1" 500 - "-" "okhttp/3.12.1"

6 个答案:

答案 0 :(得分:3)

此问题是由于最新的React Native版本0.59https://github.com/facebook/react-native/issues/24112

中的错误引起的

几个小时前已发布了修复程序。请升级为反应型0.59.2

react-native upgrade

有关如何升级的完整指南:https://facebook.github.io/react-native/docs/upgrading

答案 1 :(得分:1)

使用此

react-native start --reset-cache

这是由于RN中的问题 参考:https://github.com/facebook/react-native/issues/1924

答案 2 :(得分:0)

请按照以下步骤操作:

  1. 删除node_modules文件夹
  2. 运行npm install

答案 3 :(得分:0)

运行

反应本机开始---reset-cache

然后

react-native run-android (在单独的命令行中)

对我来说很好

祝你好运!

答案 4 :(得分:0)

请确保打包程序服务器未在下一个选项卡上运行。因此我被困住了。

答案 5 :(得分:0)

我复制了c:\reactnative\a\node_modules\react-native\scripts/.的内容,该内容是无错误运行的项目的项目目录,并替换为有错误的项目

相关问题