我有一个本机的本机应用程序运行正常,但是突然出现此错误:
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.
我第一次得到它时,我只是在测试应用程序,做了我整天都在做的事情,没有什么新鲜的东西,没有什么异常。现在,我什至无法在我的设备上启动该应用程序。
我使用以下脚本启动应用程序:package.json中的yarn start-fresh
:
"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-*
我尝试了此处列出的所有内容,但是都没有用。
任何人都可以帮助我让此应用再次运行吗?
嗯,您在使用VSCode吗?我认为编码时会在代码中自动导入模块。在vscode中,如果键入某些内容,则建议自动导入,也许您可以导入未使用的模块。请检查您未使用的模块的代码。