React-Native - 无法从 node_modules/eslint/lib/cli-engine/cli-engine.js 解析模块 fs

React-Native - Unable to resolve module fs from node_modules/eslint/lib/cli-engine/cli-engine.js

我有一个运行良好的本机反应应用程序,但突然出现此错误:

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 来自我的 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-*

我尝试了那里列出的所有内容,但 none 奏效了。

谁能帮我让这个应用程序重新运行?

那么,您在使用 VSCode 吗? 我认为您在编码时代码中有自动导入的模块。在 vscode 中,如果您输入一些内容,那么它会建议自动导入,并且您可能会导入未使用的模块。 请检查代码是否有未使用的模块。