【问题标题】:React Native the module could not be foundReact Native 找不到模块
【发布时间】:2020-01-08 03:55:14
【问题描述】:

我昨天运行了这个项目,效果很好。今天,当我使用react-native run-ios 运行我的 RN 项目时,突然找不到模块。

我项目的 React-native 版本

react-native-cli: 2.0.1
react-native: 0.52.2

我项目的守望者版本

4.9.0

我的文件夹结构

src
  components
  screens
  stores
  Config.js

以下是我的Config.js

const host = "localhost:5000";
const proto = "http://";
const api = "/api";

const Config = {
  urls: {
    signin_start: proto + host + api + "/signin/start",
    signin_verify: proto + host + api + "/signin/verify",
  }
};

export default Config;

我使用来自screens/signInStart.js 文件的配置,如下所示

import Config from "../Config";

我收到如下错误

The module `../Config` could not be found

我该如何解决?我已经通过运行以下命令来清除反应本机缓存。但是,仍然无法修复。

watchman watch-del-all && rm -rf $TMPDIR/react-* && rm -rf node_modules/ && npm cache clean && npm install && npm start -- --reset-cache

【问题讨论】:

  • 你试过“npm run ios”脚本:“ios”:“node node_modules/react-native/local-cli/cli.js run-ios”吗?

标签: javascript reactjs react-native


【解决方案1】:

找了很久,调试了很久,终于通过react native Github issue之一解决了我的问题。

  • 删除 node_modules 文件夹: rm -rf node_modules && npm install
  • 重置打包程序缓存:rm -fr $TMPDIR/react-*
  • 清除守望者手表:watchman watch-del-all
  • 从头开始重新创建项目

https://github.com/facebook/react-native/issues/4968

【讨论】:

    猜你喜欢
    • 2019-09-06
    • 1970-01-01
    • 2023-04-06
    • 1970-01-01
    • 2023-01-18
    • 2016-10-27
    • 1970-01-01
    • 1970-01-01
    • 1970-01-01
    相关资源
    最近更新 更多