无法解析模块`./index` [英] Unable to resolve module `./index`

查看:131
本文介绍了无法解析模块`./index`的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

过去几天我一直在我的代码中收到无法解析模块索引的问题,并且找到了一个临时解决方案,但无法找到永久修复.

I've been receiving an unable to resolve module index in my code the past few days and have found a temporarily solution but am unable to find a permanent fix.

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

I've been receiving this error for the past few days and have found a temporary solution when I run "npm start -- --reset-cache", but whenever i run "react-native run-android" again, the same error pops up. This is the error.

为什么会出现这个错误,如何在不每次都使用临时解决方案的情况下解决它?

Why is this error appearing and how can I solve it without using my temporary solution each time?

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"

推荐答案

这个问题是由于最新的 React Native 版本 0.59 中的一个错误引起的:https://github.com/facebook/react-native/issues/24112

This issue was caused due to a bug in the latest React Native version 0.59: https://github.com/facebook/react-native/issues/24112

几个小时前发布了修复程序.请升级到 react-native 0.59.2.

A fix has been released a few hours ago. Please upgrade to react-native 0.59.2.

react-native upgrade

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

The full guide on how to upgrade: https://facebook.github.io/react-native/docs/upgrading

这篇关于无法解析模块`./index`的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆