mswjs/mswjs.io

Issues integrating with React Native and pnpm

ianwalter opened this issue · 1 comments

Sorry I don't have a reproducible example, but when I try to follow the steps (https://mswjs.io/docs/integrations/react-native/) in a React Native project managed by pnpm, React Native errors out telling me that it can't find random dependencies. The dependency that it showed was p-retry but I don't think it's specific to that package because when I tried to rebuild it would complain about other packages being missing as well. Given that it's complaining about not finding modules that are installed, I think this is specific to pnpm. Here is the exact output:

 BUNDLE  ./index.js

error: Error: Unable to resolve module retry from /mobile/node_modules/p-retry/index.js: retry could not be found within the project or in these directories:
  node_modules
> 1 | import retry from 'retry';
    |                    ^
  2 |
  3 | const networkErrorMsgs = new Set([
  4 |   'Failed to fetch', // Chrome
    at ModuleResolver.resolveDependency (/mobile/node_modules/.pnpm/metro@0.76.9/node_modules/metro/src/node-haste/DependencyGraph/ModuleResolution.js:139:15)
    at DependencyGraph.resolveDependency (/mobile/node_modules/.pnpm/metro@0.76.9/node_modules/metro/src/node-haste/DependencyGraph.js:277:43)
    at Object.resolve (/mobile/node_modules/.pnpm/metro@0.76.9/node_modules/metro/src/lib/transformHelpers.js:173:21)
    at Graph._resolveDependencies (/mobile/node_modules/.pnpm/metro@0.76.9/node_modules/metro/src/DeltaBundler/Graph.js:482:35)
    at Graph._processModule (/mobile/node_modules/.pnpm/metro@0.76.9/node_modules/metro/src/DeltaBundler/Graph.js:267:38)
    at process.processTicksAndRejections (node:internal/process/task_queues:95:5)
    at async Graph._addDependency (/mobile/node_modules/.pnpm/metro@0.76.9/node_modules/metro/src/DeltaBundler/Graph.js:378:20)
    at async Promise.all (index 5)
    at async Graph._processModule (/mobile/node_modules/.pnpm/metro@0.76.9/node_modules/metro/src/DeltaBundler/Graph.js:328:5)
    at async Graph._addDependency (/mobile/node_modules/.pnpm/metro@0.76.9/node_modules/metro/src/DeltaBundler/Graph.js:378:20)

Oh no I posted this in the docs repo. Going to blame a lack of sleep, sorry!