Darius Biro
Darius Biro

Reputation: 189

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

I have this react-native app that worked just fine, but suddenly I get this error:

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.

The first time that I got it, I was just testing the app, doing things I have been doing all day, nothing new, nothing unusual. Now I can't even start the app on my device.

I start the app with this script: 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" 

Then in a new terminal tab, I do yarn android. It loads everything fine in this 2nd tab, but then when I go back to the first tab(where I ran yarn start-fresh), it loads some stuff but then I get the error. I don't remember installing any new package or update the packages or anything like that...

I tried searching online for solutions but I couldn't find anything helpful. Also, after the error I have this list:

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-*

I tried everything that is listed there, but none worked.

Could anyone help me make this app work again?

Upvotes: 2

Views: 2460

Answers (1)

Shing Ho Tan
Shing Ho Tan

Reputation: 951

Well, are you using VSCode? I think there is auto imported module in your code while you're coding. In the vscode, if you type something, then it suggests auto-import and maybe you import unused modules. Please check the codes that you have unused modules.

Upvotes: 7

Related Questions