pnpm: [bug] - Pnpm not working with expo
pnpm version:
6.28.0
Code to reproduce the issue:
expo init pnpm_expo # Choose Typescript tab template
cd pnpm_expo
rm -rf node_modules yarn.lock
pnpm i
pnpm start
# Go to the expo app, and try it
Expected behavior:
Be able to run an expo app without any issue.
Actual behavior:
Error: EISDIR: illegal operation on a directory, read
at Object.readSync (node:fs:723:3)
at tryReadSync (node:fs:433:20)
at Object.readFileSync (node:fs:479:19)
at UnableToResolveError.buildCodeFrameMessage (/home/olyno/Documents/projects/pnpm_expo/node_modules/.pnpm/metro@0.64.0/node_modules/metro/src/node-haste/DependencyGraph/ModuleResolution.js:347:17)
at new UnableToResolveError (/home/olyno/Documents/projects/pnpm_expo/node_modules/.pnpm/metro@0.64.0/node_modules/metro/src/node-haste/DependencyGraph/ModuleResolution.js:333:35)
at ModuleResolver.resolveDependency (/home/olyno/Documents/projects/pnpm_expo/node_modules/.pnpm/metro@0.64.0/node_modules/metro/src/node-haste/DependencyGraph/ModuleResolution.js:211:15)
at DependencyGraph.resolveDependency (/home/olyno/Documents/projects/pnpm_expo/node_modules/.pnpm/metro@0.64.0/node_modules/metro/src/node-haste/DependencyGraph.js:413:43)
at /home/olyno/Documents/projects/pnpm_expo/node_modules/.pnpm/metro@0.64.0/node_modules/metro/src/lib/transformHelpers.js:317:42
at /home/olyno/Documents/projects/pnpm_expo/node_modules/.pnpm/metro@0.64.0/node_modules/metro/src/Server.js:1471:14
at Generator.next (<anonymous>)
› Stopped server
Additional information:
node -vprints: 16.13.2- Windows, macOS, or Linux?: Linux, Deepin
About this issue
- Original URL
- State: open
- Created 2 years ago
- Reactions: 4
- Comments: 15 (2 by maintainers)
@byCedric now that Expo SDK 50 uses React Native 0.73 (which made the Metro symlinks support stable, which has been reported as working by the community without Expo), would it be considered a bug in Expo for pnpm support to not work out of the box (without
node-linker=hoistedor any other workarounds) with a newcreate-expoapp?The way I understand it, the work involved on Expo’s side for supporting symlinks would be refactoring the following:
node_modulesnode_modulesstructureWould be great to be able to use Expo + the new Metro symlink support without the
node-linker=hoistedworkaround!@zkochan alternatively, if Expo will not do the work above to support symlinks, would
pnpmconsider adopting into core somepublic-hoist-pattern[]hoisting exceptions config for Expo and related packages which rely on a fixednode_modulesdirectory structure?Some users have reported
public-hoist-pattern[]configurations working for them:eg. the following (not tested as working yet)
I know that
pnpmalready has somepublic-hoist-pattern[]configuration in core for some other popular packages in the ecosystem which also rely onnode_modulesdirectory structure - so I’m asking whetherpnpmwould also consider this for Expo, if they will not do the work to refactor.That’s not an issue related to pnpm, or Expo. It’s just how Metro explains it can’t find packages. I got it working with the
--shamefully-hoistflag, and going over the steps in Working with Monorepos, in case it helps. https://github.com/byCedric/eas-monorepo-example/pull/19Thanks. I actually looked into that just now and these are the specific changes necessary for pnpm: https://github.com/rhyek/expo-monorepo-issue/compare/pnpm...pnpm-fixed
It works this way, but isn’t it contrary to the principle of operation of pnpm? The purpose of pnpm is to use symlinks to reduce the size of
node_modules, isn’t it?@wesleyfreit @watadarkstar these two configurations are not following my suggested
public-hoist-pattern[]=config above:node-linker=hoisted, which is a workaround for the issue and avoids the problem which should actually be fixed by Expo / React Native / pnpm (description on option: “A React Native project will most probably only work if you use a hoisted node_modules.”)The point of issues like this are to try to move past the historical limitation of React Native to not work with symlinks and pnpm’s default
isolatedlinker, now that Expo SDK 50 uses React Native 0.73, which made the Metro symlinks support stable:Yes, @karlhorky is correctly, my project is working good using
public-hoist-pattern[]pnpm configuration in.npmrcand other configurations inmetro.config.js.I’m using a default expo project created inside the monorepo using turborepo with pnpm.
My
.npmrc:In my expo project, I have the
@rnx-kit/metro-resolver-symlinkspackage installed.And my
metro.config.js:In my project, the typescript path mapping configuration (ex:
@/), did not work with the described configuration, so I had to remove it. Maybe I should add another public pattern for typescript, but I preferred not to add it.Right. But we can’t fix issues in third party libs. The global store is still used. Even with hoisted linker
Try with the
node-linker=hoistedoption https://pnpm.io/npmrc#node-linker