[expo-yarn-workspaces] wrong generated symlink to react-native-unimodules

🐛 Bug Report

Summary of Issue

Probably there is something wrong with the symlink react-native-unimodules generated by expo-yarn-workspaces package because there is no package named react-native-unimodules in workspace root, even if I generate a new empty Expo Project (Managed workflow) using expo-cli. So the symbolic link results invalid and the app does not start.

The commit that introduces these symlinks related (probably) to bare projects is #11402 in 47f64b7#diff-23f8ed82fd6740272240ae123b2fb95254ac7d6b2c0e91314b52da514849b04eR21

Environment – output of expo diagnostics & the platform(s) you’re targeting

  Expo CLI 4.0.17 environment info:
    System:
      OS: macOS 11.1
      Shell: 5.8 - /bin/zsh
    Binaries:
      Node: 15.2.0 - ~/.nvm/versions/node/v15.2.0/bin/node
      Yarn: 1.22.10 - ~/.nvm/versions/node/v15.2.0/bin/yarn
      npm: 7.0.11 - ~/.nvm/versions/node/v15.2.0/bin/npm
      Watchman: 4.9.0 - /usr/local/bin/watchman
    Managers:
      CocoaPods: 1.10.0 - /usr/local/bin/pod
    SDKs:
      iOS SDK:
        Platforms: iOS 14.3, DriverKit 20.2, macOS 11.1, tvOS 14.3, watchOS 7.2
      Android SDK:
        API Levels: 30
        Build Tools: 30.0.2, 30.0.3
        System Images: android-30 | Google APIs Intel x86 Atom, android-30 | Google Play Intel x86 Atom
    IDEs:
      Android Studio: 4.1 AI-201.8743.12.41.6953283
      Xcode: 12.3/12C33 - /usr/bin/xcodebuild
    npmPackages:
      expo: ^40.0.0 => 40.0.0 
      react-native: https://github.com/expo/react-native/archive/sdk-40.0.1.tar.gz => 0.63.2 
    npmGlobalPackages:
      expo-cli: 4.0.17
    Expo Workflow: managed

Expected Behavior vs Actual Behavior

Expected:
The app starts without error.

Actual:
When I try to start the app I see this error:

$ expo start --clear
Starting project at /Users/cesconix/workspace/monorepo/apps/work-app
Expo DevTools is running at http://localhost:19002
Opening DevTools in the browser... (press shift-d to disable)
ENOENT: no such file or directory, stat '/Users/cesconix/workspace/monorepo/apps/work-app/node_modules/react-native-unimodules'
Error: ENOENT: no such file or directory, stat '/Users/cesconix/workspace/monorepo/apps/work-app/node_modules/react-native-unimodules'
    at Object.realpathSync (node:fs:1776:9)
    at getSymlinkedNodeModulesForDirectory (/Users/cesconix/workspace/monorepo/node_modules/expo-yarn-workspaces/index.js:98:38)
    at createMetroConfiguration (/Users/cesconix/workspace/monorepo/node_modules/expo-yarn-workspaces/index.js:32:10)
    at Object.<anonymous> (/Users/cesconix/workspace/monorepo/apps/work-app/metro.config.js:3:18)
    at Module._compile (node:internal/modules/cjs/loader:1102:14)
    at Object.Module._extensions..js (node:internal/modules/cjs/loader:1131:10)
    at Module.load (node:internal/modules/cjs/loader:967:32)
    at Function.Module._load (node:internal/modules/cjs/loader:807:14)
    at Module.require (node:internal/modules/cjs/loader:991:19)
    at require (node:internal/modules/cjs/helpers:92:18)

3 thoughts on “[expo-yarn-workspaces] wrong generated symlink to react-native-unimodules

  1. Hi @cesconix, thanks for writing in! Yes, you are right that expo-yarn-workspaces@1.3.0 seems to cause issues with managed expo projects. I can reproduce this error using npx create-react-native-app -t with-yarn-workspaces. One thing you can do to work around this issue until we resolved this, is pinning expo-yarn-workspaces to 1.2.1.

    cc @EvanBacon looks like these new dependencies are for bare projects only, should we add logic to this code to check if the library exists or not?

  2. Hi @cesconix, we just released a new version 1.3.1 that should include a fix for this issue. If you could try that out, that would be amazing. In case you encounter any issues with this, you can @me in this issue 😄

    Hope this helps!

    It works, thanks!