【问题标题】:React-Native - Unable to resolve module fs from node_modules/eslint/lib/cli-engine/cli-engine.jsReact-Native - 无法从 node_modules/eslint/lib/cli-engine/cli-engine.js 解析模块 fs
【发布时间】:2020-04-25 18:09:29
【问题描述】:

我有这个运行良好的 react-native 应用程序,但突然我收到这个错误:

error: bundling failed: Error: Unable to resolve module `fs` from `node_modules/eslint/lib/cli-engine/cli-engine.js`: fs could not be found within the project.

我第一次得到它时,只是在测试应用程序,做我一整天都在做的事情,没有什么新鲜的,没有什么不寻常的。现在我什至无法在我的设备上启动应用程序。

我用这个脚本启动应用程序:yarn start-fresh from my package.json:

"start-fresh": "cd android/ && ./gradlew clean && cd .. && rm -rf node_modules/ && yarn install && react-native start --reset-cache" 

然后在一个新的终端选项卡中,我执行yarn android。它在第二个选项卡中加载一切正常,但是当我返回第一个选项卡(我在其中运行 yarn start-fresh)时,它加载了一些内容,但随后出现错误。我不记得安装任何新软件包或更新软件包或类似的东西......

我尝试在线搜索解决方案,但找不到任何有用的信息。另外,在错误之后我有这个列表:

If you are sure the module exists, try these steps:
 1. Clear watchman watches: watchman watch-del-all
 2. Delete node_modules: rm -rf node_modules and run yarn install
 3. Reset Metro's cache: yarn start --reset-cache
 4. Remove the cache: rm -rf /tmp/metro-*

我尝试了那里列出的所有方法,但都没有成功。

谁能帮我让这个应用再次运行?

【问题讨论】:

  • 你在代码中使用 react-native-fs 吗?

标签: react-native eslint yarnpkg


【解决方案1】:

嗯,你在使用 VSCode 吗? 我认为在您编码时,您的代码中有自动导入的模块。在 vscode 中,如果你输入一些东西,那么它会建议自动导入,也许你会导入未使用的模块。 请检查您有未使用的模块的代码。

【讨论】:

  • 天啊...我觉得很愚蠢...我认为您是对的...我刚刚回到我项目的最后一个工作推送请求,它就是这样工作的。我很确定我只是错误地在某个地方输入了 fs ,这就是它不起作用的原因。无论如何,我只是让它工作,但我认为这是原因。谢谢你的时间。 :)
猜你喜欢
  • 2022-01-08
  • 2016-12-27
  • 2017-07-29
  • 2018-04-04
  • 2022-11-12
  • 1970-01-01
  • 1970-01-01
  • 1970-01-01
  • 2020-11-05
相关资源
最近更新 更多