expo: expo yarn workspace not working on windows

🐛 Bug Report

Environment

Expo CLI 3.11.9 environment info: System: OS: Windows 10 Binaries: Yarn: 1.21.1 - C:\Program Files (x86)\Yarn\bin\yarn.CMD npm: 6.13.1 - C:\Program Files\nodejs\npm.CMD

Target: iOS / Android

Steps to Reproduce

Have a monorepo with lerna / yarn workspace. Follow the expo-yarn-workspace installation steps. Folder structure:

  • package.json (nothing special there)
  • packages ** mobile (name: @myapp/mobile) *** package.json (expo-yarn-workspace installed as dev dependency and postinstall script).

When I run yarn add somePackage, it fails with this error:

error D:\aaa\project\node_modules\@myapp\mobile: Command failed.
Exit code: 1
Command: expo-yarn-workspaces postinstall
Arguments:
Directory: D:\aaa\project\node_modules\@myapp\mobile
Output:
internal/modules/cjs/loader.js:964
    throw err;
    ^
Error: Cannot find module 'D:\aaa\project\node_modules\node_modules\expo-yarn-workspaces\bin\expo-yarn-workspaces.js'
    at Function.Module._resolveFilename (internal/modules/cjs/loader.js:961:17)
    at Function.Module._load (internal/modules/cjs/loader.js:854:27)
    at Function.executeUserEntryPoint [as runMain] (internal/modules/run_main.js:71:12)

Expected Behavior

Same config is working on mac without problem. I expect it to work on windows as well.

Actual Behavior

I can execute the script with yarn postinstall without any problem. The problem is when it’s auto executed with a new package install.

I hope I put enough informations. Thanks for you help

About this issue

  • Original URL
  • State: closed
  • Created 4 years ago
  • Reactions: 8
  • Comments: 22 (5 by maintainers)

Commits related to this issue

Most upvoted comments

I’ve noticed the package works on windows but you have to remove the script from the app’s package.json and add it to the main package.json in such a way: "postinstall":"cd ./packages/expoapp && expo-yarn-workspaces postinstall" Maybe that helps

As another Windows 10 user, I can confirm I’m also seeing this exact same problem.

this happens with me too

I’ve noticed the package works on windows but you have to remove the script from the app’s package.json and add it to the main package.json in such a way: "postinstall":"cd ./packages/expoapp && expo-yarn-workspaces postinstall" Maybe that helps

Sadly, it doesn’t work at my side with the following error:

internal/fs/utils.js:220
    throw err;
    ^

Error: EPERM: operation not permitted, symlink '..\..\..\node_modules\expo' -> 'C:\Users\xxx\Workplace\monorepo\packages\native\node_modules\expo'
    at Object.symlinkSync (fs.js:994:3)
    at symlinkNecessaryPackage (C:\Users\xxx\Workplace\monorepo\node_modules\expo-yarn-workspaces\bin\symlink-necessary-packages.js:65:8)
    at symlinkNecessaryPackages (C:\Users\xxx\Workplace\monorepo\node_modules\expo-yarn-workspaces\bin\symlink-necessary-packages.js:17:3)
    at Object.<anonymous> (C:\Users\xxx\Workplace\monorepo\node_modules\expo-yarn-workspaces\bin\symlink-necessary-packages.js:81:3)
    at Module._compile (internal/modules/cjs/loader.js:955:30)
    at Object.Module._extensions..js (internal/modules/cjs/loader.js:991:10)
    at Module.load (internal/modules/cjs/loader.js:811:32)
    at Function.Module._load (internal/modules/cjs/loader.js:723:14)
    at Function.Module.runMain (internal/modules/cjs/loader.js:1043:10)
    at internal/main/run_main_module.js:17:11 {
  errno: -4048,
  syscall: 'symlink',
  code: 'EPERM',
  path: '..\\..\\..\\node_modules\\expo',
  dest: 'C:\\Users\\xxx\\Workplace\\monorepo\\packages\\native\\node_modules\\expo'
}

Main package.json

{
  "...": "...",
  "workspaces": [
    "packages/**/*"
  ],
  "scripts": {
    "postinstall":"cd ./packages/native && expo-yarn-workspaces postinstall"
  },
  "dependencies": {
    "...": "..."
  }
}

Expo package.json

{
  "...": "...",
  "main": "__generated__/AppEntry.js",
  "scripts": {
    "start": "expo start",
    "android": "expo start --android",
    "ios": "expo start --ios",
    "web": "expo start --web",
    "eject": "expo eject"
  },
  "dependencies": {
    "@monorepo/components": "1.0.0",
    "expo": "36.0.2",
    "react": "16.13.1",
    "...": "...",
  },
  "devDependencies": {
    "...": "...",
    "expo-yarn-workspaces": "1.2.1"
  }
}

It is giving operation not allowed. only use Windows PowerShell as an administrator. and it will already work.

I’ve noticed the package works on windows but you have to remove the script from the app’s package.json and add it to the main package.json in such a way: "postinstall":"cd ./packages/expoapp && expo-yarn-workspaces postinstall" Maybe that helps

Sadly, it doesn’t work at my side with the following error:

internal/fs/utils.js:220
    throw err;
    ^

Error: EPERM: operation not permitted, symlink '..\..\..\node_modules\expo' -> 'C:\Users\xxx\Workplace\monorepo\packages\native\node_modules\expo'
    at Object.symlinkSync (fs.js:994:3)
    at symlinkNecessaryPackage (C:\Users\xxx\Workplace\monorepo\node_modules\expo-yarn-workspaces\bin\symlink-necessary-packages.js:65:8)
    at symlinkNecessaryPackages (C:\Users\xxx\Workplace\monorepo\node_modules\expo-yarn-workspaces\bin\symlink-necessary-packages.js:17:3)
    at Object.<anonymous> (C:\Users\xxx\Workplace\monorepo\node_modules\expo-yarn-workspaces\bin\symlink-necessary-packages.js:81:3)
    at Module._compile (internal/modules/cjs/loader.js:955:30)
    at Object.Module._extensions..js (internal/modules/cjs/loader.js:991:10)
    at Module.load (internal/modules/cjs/loader.js:811:32)
    at Function.Module._load (internal/modules/cjs/loader.js:723:14)
    at Function.Module.runMain (internal/modules/cjs/loader.js:1043:10)
    at internal/main/run_main_module.js:17:11 {
  errno: -4048,
  syscall: 'symlink',
  code: 'EPERM',
  path: '..\\..\\..\\node_modules\\expo',
  dest: 'C:\\Users\\xxx\\Workplace\\monorepo\\packages\\native\\node_modules\\expo'
}

Main package.json


{
  "...": "...",
  "workspaces": [
    "packages/**/*"
  ],
  "scripts": {
    "postinstall":"cd ./packages/native && expo-yarn-workspaces postinstall"
  },
  "dependencies": {
    "...": "..."
  }
}

Expo package.json

{
  "...": "...",
  "main": "__generated__/AppEntry.js",
  "scripts": {
    "start": "expo start",
    "android": "expo start --android",
    "ios": "expo start --ios",
    "web": "expo start --web",
    "eject": "expo eject"
  },
  "dependencies": {
    "@monorepo/components": "1.0.0",
    "expo": "36.0.2",
    "react": "16.13.1",
    "...": "...",
  },
  "devDependencies": {
    "...": "...",
    "expo-yarn-workspaces": "1.2.1"
  }
}

Not sure what the cause is but added a note to the README saying it works only on Mac and Linux: https://github.com/expo/expo/blob/master/packages/expo-yarn-workspaces/README.md

@NiallJoeMaher did you get a chance to create a remote container for windows development?

I’ll push up one later today or early tomorrow. 💜

Using the "prepare" script instead of "postinstall" seems to work as well

EDIT: Never mind, this was a quirk of my local setup, it seems