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

Dar*_*iro 2 eslint react-native yarnpkg

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

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.
Run Code Online (Sandbox Code Playgroud)

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

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

"start-fresh": "cd android/ && ./gradlew clean && cd .. && rm -rf node_modules/ && yarn install && react-native start --reset-cache" 
Run Code Online (Sandbox Code Playgroud)

然后在一个新的终端选项卡中,我执行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-*
Run Code Online (Sandbox Code Playgroud)

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

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

Shi*_*Tan 6

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