Skip to content
This repository has been archived by the owner on Jan 18, 2024. It is now read-only.

yarn v2 support #1073

Closed
satishbabariya opened this issue Oct 5, 2019 · 13 comments
Closed

yarn v2 support #1073

satishbabariya opened this issue Oct 5, 2019 · 13 comments
Assignees
Labels
enhancement New feature or request help wanted Extra attention is needed

Comments

@satishbabariya
Copy link

Error: node_modules directory is missing. Please run npm install in your project directory.

when using yarn v2 expo can't able to find node_modules folder ( due to yarn v2 dosn't use them instead it uses cache with zip)

Expo DevTools is running at http://localhost:19002
Opening DevTools in the browser... (press shift-d to disable)
Error: node_modules directory is missing. Please run `npm install` in your project directory.
Couldn't start project. Please fix the errors and restart the project.
Set EXPO_DEBUG=true in your env to view the stack trace.

@fson fson added enhancement New feature or request help wanted Extra attention is needed labels Nov 8, 2019
@brentvatne
Copy link
Member

@satishbabariya - anything we can do to help you add support for this in expo-cli?

@satishbabariya
Copy link
Author

@brentvatne, I think we need to add support for yarn's PnP API.
https://next.yarnpkg.com/advanced/pnpapi
https://next.yarnpkg.com/advanced/pnpify

@brentvatne
Copy link
Member

i personally don't have time to work on that but contributions are welcome!

@fson fson removed the help wanted Extra attention is needed label Jan 25, 2020
@fson fson self-assigned this Jan 25, 2020
@fson
Copy link
Contributor

fson commented Jan 28, 2020

Right now Metro doesn't support the Plug'n'Play mode, which is enabled by Berry (Yarn v2) by default (at least in the current 2.0.0-rc.27 version), so the most promising path to get Berry working would be using the node-modules plugin, which creates a backwards compatible node_modules folder. The plugin is enabled by creating a .yarnrc.yml file with the following contents in the project folder:

nodeLinker: node-module

However, there seems to be a bug in Yarn 2.0.0-rc.27, which makes the yarn install command hang indefinitely in this mode:

% rm -rf node_modules 
 % yarn -v 
2.0.0-rc.27
% yarn               
➤ YN0000: ┌ Resolution step
➤ YN0002: │ babel-preset-expo@npm:8.0.0 doesn't provide @babel/core@* requested by metro-react-native-babel-preset@npm:0.56.4
➤ YN0002: │ babel-preset-expo@npm:8.0.0 doesn't provide @babel/core@^7.0.0-0 requested by @babel/plugin-proposal-decorators@npm:7.8.3
➤ YN0002: │ babel-preset-expo@npm:8.0.0 doesn't provide @babel/core@^7.0.0-0 requested by @babel/preset-env@npm:7.8.3
➤ YN0002: │ expo@npm:36.0.2 doesn't provide react-native@* requested by @unimodules/react-native-adapter@npm:5.0.0
➤ YN0002: │ expo@npm:36.0.2 doesn't provide react@* requested by react-native-view-shot@npm:3.0.2
➤ YN0002: │ expo@npm:36.0.2 doesn't provide react-native@* requested by react-native-view-shot@npm:3.0.2
➤ YN0000: └ Completed in 0.32s
➤ YN0000: ┌ Fetch step
➤ YN0000: └ Completed in 1.26s
➤ YN0000: ┌ Link step
➤ YN0007: │ core-js@npm:2.6.11 must be built because it never did before or the last one failed
➤ YN0000: └ Completed in 22.57s
➤ YN0000: Done with warnings in 24.2s
➤ YN0000: ⠹ ===============================================================================
^C%                                                                                                                                       

The command hangs indefinitely and the progress bar doesn't go away until yarn is terminated with ctrl-c. On the next run it finishes, but it seems that some packages are missing:

Attempting to open the project in a web browser...
(node:15094) UnhandledPromiseRejectionWarning: Error: Cannot find module 'worker-loader'
Require stack:
- /Users/ville/Projects/expo-cli/packages/webpack-config/webpack/loaders/createWorkerLoader.js
...

@scriptmaster

This comment has been minimized.

@tiagob
Copy link

tiagob commented Aug 13, 2020

This works for me in my expo app

In .yarnrc.yml

nodeLinker: node-module
% yarn --version
2.1.1

Like @fson said, Plug'n'Play has issues with Metro

@EvanBacon EvanBacon added the help wanted Extra attention is needed label Nov 26, 2020
@github-actions
Copy link

This issue is stale because it has been open for 60 days with no activity. If there is no activity in the next 7 days, the issue will be closed.

@github-actions github-actions bot added the stale label Apr 13, 2022
@alamothe
Copy link

bump

@github-actions github-actions bot removed the stale label Apr 13, 2022
@mekwall
Copy link

mekwall commented Jul 15, 2022

No reason to bump this. It's not something Expo can fix since React Native doesn't support Yarn PnP. It is tracked in react-native-community/cli#27 and facebook/metro#308

@Nantris
Copy link

Nantris commented Aug 5, 2022

@mekwall this comment seems to suggest maybe otherwise: facebook/metro#308 (comment)

But without some more reading I can't know whether that's truly relevant. I don't think that this issue is solely about PnP support, but correct me if I'm wrong.

@Nantris
Copy link

Nantris commented Mar 23, 2023

Any movement on this? Expo has been holding us back from upgrading Yarn for years now.

@mekwall
Copy link

mekwall commented Mar 24, 2023

Any movement on this? Expo has been holding us back from upgrading Yarn for years now.

See my comment above. This is not an Expo issue. You can upgrade Yarn to v3 and use it without PnP and it will work just fine with Expo and React Native. It's documented here: https://yarnpkg.com/getting-started/migration

vecchp added a commit to BetterAngelsLA/monorepo that referenced this issue Aug 16, 2023
Ticket IDs: 4954909653, 4954931590, 4954946135, 4954945454, 4954946646

Introduced basic configurations for:
- NX
- Expo
- Prettier
- ESLint
- TypeScript
- Configured Yarn 3 with node_modules linker instead of PnP. expo/expo-cli#1073
- Updated the VSCode dev-container with relevant extensions to streamline the development setup.

Co-authored-by: Davit-BetterAngels <davit@betterangels.la>
@byCedric
Copy link
Member

byCedric commented Dec 28, 2023

Hi all! Expo now supports npm, yarn@1, and bun without any additional setup. yarn@2+ and pnpm requires additional setup for now:

  • pnpm requires a .npmrc file, containing node-linker=hoisted (docs)
  • yarn v2+ requires a .yarnrc.yml file, containing nodeLinker: node-modules (docs)

Hope this helps!

Sign up for free to subscribe to this conversation on GitHub. Already have an account? Sign in.
Labels
enhancement New feature or request help wanted Extra attention is needed
Projects
None yet
Development

No branches or pull requests

10 participants