Flipper: Question: Yarn start Failed with "Error: Unable to resolve module `react-redux`"

Created on 27 Feb 2020  路  12Comments  路  Source: facebook/flipper

Environment
node: v13.8.0
yarn: 1.22.0
npm: 6.13.7
mac: mojave

There has an error when build from source:

error: Error: Unable to resolve module react-redux from src/init.tsx: react-redux could not be found within the project or in these directories:
node_modules

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 reinstall node\yarn\npm, can't resolve it. Please Help....

Most helpful comment

@nikoant Has a fix for this. This should be in master in just a bit.

All 12 comments

Sorry if I missed this in the report, but what are you trying to build? Is a plugin or just the repository checkout? Could you please list the exact steps you took from cloning the repository to what yarn commands you ran?

Hey @passy I started randomly getting this error the other night just trying to yarn start the repo. I have tried deleting ~/.flipper/plugins to force rebuilding the plugins, removed all custom plugin paths, deleted node_modules and re-installed, cleared metro cache and still get the error. I even pulled a fresh copy of the repo into a different directory and yarn && yarn start and got the same error.

Update: I have gone back to the commit for version 0.32.0 and still get this error when I was not getting it on the latest version last week. I suspect it is something being cached outside of the flipper directory

Further Researching: If I go into init.tsx in the src directory and simply comment out the import of react-redux (which is the first one) the error then switches to react-dom (the next one). This makes me feel like it is something with metro that is failing to pull the modules from node_modules

Even more: Logging out Metro internals it seems like it is just looking for index.[ext] at the root of the folders instead of looking at the package json file for the main, module, etc. I am digging into this more to see if I am missing anything in what it is searching.

Can confirm, I have the same issue.

Steps to reproduce

  1. git clone https://github.com/facebook/flipper.git
  2. cd flipper
  3. yarn
  4. yarn start

Info
OS: Linux
NPM: 6.13.2
Yarn: 1.22.0

Error
error: Error: Unable to resolve module react-redux from src/init.tsx: react-redux could not be found within the project or in these directories:
node_modules

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-*
    at ModuleResolver.resolveDependency (/develop/flipper/static/node_modules/metro/src/node-haste/DependencyGraph/ModuleResolution.js:186:15)
    at ResolutionRequest.resolveDependency (/develop/flipper/static/node_modules/metro/src/node-haste/DependencyGraph/ResolutionRequest.js:52:18)
    at DependencyGraph.resolveDependency (/develop/flipper/static/node_modules/metro/src/node-haste/DependencyGraph.js:287:16)
    at Object.resolve (/develop/flipper/static/node_modules/metro/src/lib/transformHelpers.js:267:42)
    at dependencies.map.result (/develop/flipper/static/node_modules/metro/src/DeltaBundler/traverseDependencies.js:434:31)
    at Array.map ()
    at resolveDependencies (/develop/flipper/static/node_modules/metro/src/DeltaBundler/traverseDependencies.js:431:18)
    at /develop/flipper/static/node_modules/metro/src/DeltaBundler/traverseDependencies.js:275:33
    at Generator.next ()
    at asyncGeneratorStep (/develop/flipper/static/node_modules/metro/src/DeltaBundler/traverseDependencies.js:87:24)

Same issue on Arch Linux: I tried to remove yarn and metro caches and re-fetch the whole flipper repo from scratch but it didn't help.

@nikoant ideas?

@mweststrate, no ideas for now, but I also reproduced this on Windows machine. However after yarn reset + yarn install the issue has gone away.

Options I tried:

watchman watch-del-all
yarn reset cache
rm -rf node_modules
rm -rf /tmp/metro-*
rm -rf /tmp/flipper
rm -rf static/node_modules

And also tried passing resetCache: true to runMetro here.

None worked, however, using my fork (70 commits behind) did work on the first try.

@nikoant Has a fix for this. This should be in master in just a bit.

The fix is in master now, please test it on your machines.

For me works fine now on both macOS and Windows.

One note: I had to kill my watchman instance before the fix worked for me because it didn't seem to pick up the changes to .watchmanconfig automatically.

After that, it worked, too.

The fix worked, thanks.
@nikoant could you please tag a new version so it can be shipped in distros?

Was this page helpful?
0 / 5 - 0 ratings