为什么反应本机应用程序不断询问被删除的main.js?

时间:2019-02-27 03:44:41

标签: react-native

我正在通过编写一个非常简单的聊天应用程序来学习本机(0.58.5)。 Chat.js下有一个模块components。但是错误不断要求在Main.js下缺少名为components的模块。在启动“ react-native run-android Main.js Main.js . And the error is the same even if I put the components”之前,模块back under已删除。这是错误:

 DELTA  [android, dev] ..\..\../index.js ░░░░░░░░░░░░░░░░ 0.0% (0/1)::ffff:127.0.0.1 - - [27/Feb/2019:03:12:59 +0000] "GET /index.delta?platform=android&dev=true&minify=false HTTP/1.1" 500 - "-" "okhttp/3.12.1"
error: bundling failed: Error: Unable to resolve module `./components/Main` from `C:\D\code\js\emps_app\App.js`: The module `./components/Main` could not be found from `C:\D\code\js\emps_app\App.js`. Indeed, none of these files exist:
  * `C:\D\code\js\emps_app\components\Main(.native||.android.js|.native.js|.js|.android.json|.native.json|.json|.android.ts|.native.ts|.ts|.android.tsx|.native.tsx|.tsx)`
  * `C:\D\code\js\emps_app\components\Main\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:\D\code\js\emps_app\node_modules\metro\src\node-haste\DependencyGraph\ModuleResolution.js:163:15)
    at ResolutionRequest.resolveDependency (C:\D\code\js\emps_app\node_modules\metro\src\node-haste\DependencyGraph\ResolutionRequest.js:52:18)
    at DependencyGraph.resolveDependency (C:\D\code\js\emps_app\node_modules\metro\src\node-haste\DependencyGraph.js:273:16)
    at Object.resolve (C:\D\code\js\emps_app\node_modules\metro\src\lib\transformHelpers.js:261:42)
    at dependencies.map.result (C:\D\code\js\emps_app\node_modules\metro\src\DeltaBundler\traverseDependencies.js:391:31)
    at Array.map (<anonymous>)
    at resolveDependencies (C:\D\code\js\emps_app\node_modules\metro\src\DeltaBundler\traverseDependencies.js:388:18)
    at C:\D\code\js\emps_app\node_modules\metro\src\DeltaBundler\traverseDependencies.js:261:33
    at Generator.next (<anonymous>)
    at asyncGeneratorStep (C:\D\code\js\emps_app\node_modules\metro\src\DeltaBundler\traverseDependencies.js:87:24)
 DELTA  [android, dev] ..\..\../index.js ░░░░░░░░░░░░░░░░ 0.0% (0/1), failed.

这里是App.js

import React, { Component } from "react";
import Chat from "./components/Chat";

export default class App extends Component {
  render() {
    return <Chat />;
  }
}

以上完全没有引用Main.js。是Main.js中的React Native保留模块吗?

1 个答案:

答案 0 :(得分:1)

搜索index.android.bundle并从您的android文件夹中删除。

杀死地铁捆绑器的所有实例。

在项目的android文件夹的cmd或powershell中运行gradlew clean

点击react-native run-android