Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We鈥檒l occasionally send you account related emails.

Already on GitHub? Sign in to your account

expo yarn workspace not working on windows #6983

Closed
SebSchwartz opened this issue Feb 6, 2020 · 22 comments
Closed

expo yarn workspace not working on windows #6983

SebSchwartz opened this issue Feb 6, 2020 · 22 comments

Comments

@SebSchwartz
Copy link

馃悰 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

@SebSchwartz SebSchwartz added the bug label Feb 6, 2020
@Ravnurin
Copy link

Ravnurin commented Feb 7, 2020

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

@wendelfreitas
Copy link

this happens with me too

@ide
Copy link
Member

ide commented Feb 10, 2020

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

@wendelfreitas
Copy link

I'm not sure but I think that is a windows path problem when generating the binaries node_modules/.bin

@JacaD
Copy link

JacaD commented Feb 17, 2020

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

@itsMapleLeaf

This comment has been minimized.

@wendelfreitas
Copy link

@kingdaro didn't work for me :(

@NiallJoeMaher
Copy link

Would it help if we added a vscode container so windows users can use a Linux terminal while running it? https://code.visualstudio.com/docs/remote/containers

@NiallJoeMaher
Copy link

I can create/test one so people could get up and running in windows at least

@jonlu
Copy link

jonlu commented Jun 2, 2020

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

@NiallJoeMaher
Copy link

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

I'll push up one later today or early tomorrow. 馃挏

@AnLuoRidge
Copy link

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"
  }
}

@IsraelSampaio
Copy link

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.

@Silventino
Copy link

Any updates on this issue?

@mauriciord
Copy link
Contributor

@soletan
Copy link

soletan commented Oct 29, 2020

Having issues with double registration of RNCSafeViewArea* and can't follow instructions provided in an issue related to that because expo install is mediately trying to remove itself. This is pretty annoying. And this is just because Google rejected previous build due to Facebook Ad SDK secretly included with those builds, now facing tons of new issues after trying to upgrade SDK ...

$ expo install react-native-safe-area-context
Installing 1 SDK 39.0.0 compatible native module using Yarn.
> yarn add react-native-safe-area-context@3.1.4
yarn add v1.22.5
[1/4] Resolving packages...
[2/4] Fetching packages...
info fsevents@1.2.13: The platform "win32" is incompatible with this module.
info "fsevents@1.2.13" is an optional dependency and failed compatibility check. Excluding it from installation.
[3/4] Linking dependencies...
error An unexpected error occurred: "EPERM: operation not permitted, unlink 'C:\\Users\\cepharum\\PhpstormProjects\\kieznetz-react-native\\node_modules\\.bin\\expo'".
info If you think this is a bug, please open a bug report with the information provided in "C:\\Users\\cepharum\\PhpstormProjects\\kieznetz-react-native\\yarn-error.log".
info Visit https://yarnpkg.com/en/docs/cli/add for documentation about this command.
yarnpkg exited with non-zero code: 1
Error: yarnpkg exited with non-zero code: 1
    at ChildProcess.completionListener (C:\Users\cepharum\AppData\Roaming\npm\node_modules\expo-cli\node_modules\@expo\spawn-async\src\spawnAsync.ts:65:13)
    at Object.onceWrapper (events.js:421:26)
    at ChildProcess.emit (events.js:314:20)
    at ChildProcess.cp.emit (C:\Users\cepharum\AppData\Roaming\npm\node_modules\expo-cli\node_modules\cross-spawn\lib\enoent.js:34:29)
    at maybeClose (internal/child_process.js:1021:16)
    at Process.ChildProcess._handle.onexit (internal/child_process.js:286:5)
    ...
    at Object.spawnAsync [as default] (C:\Users\cepharum\AppData\Roaming\npm\node_modules\expo-cli\node_modules\@expo\spawn-async\src\spawnAsync.ts:26:19)
    at YarnPackageManager._runAsync (C:\Users\cepharum\AppData\Roaming\npm\node_modules\expo-cli\node_modules\@expo\package-manager\src\NodePackageManagers.ts:288:31)
    at YarnPackageManager.addAsync (C:\Users\cepharum\AppData\Roaming\npm\node_modules\expo-cli\node_modules\@expo\package-manager\src\NodePackageManagers.ts:241:16)
    at installAsync (C:\Users\cepharum\AppData\Roaming\npm\node_modules\expo-cli\src\commands\install.ts:129:3)
    at Command.<anonymous> (C:\Users\cepharum\AppData\Roaming\npm\node_modules\expo-cli\src\exp.ts:332:7)

@brentvatne
Copy link
Member

@soletan - it's not clear to me how this is related to expo. all expo is doing here is running yarn add:

$ expo install react-native-safe-area-context
Installing 1 SDK 39.0.0 compatible native module using Yarn.
> yarn add react-native-safe-area-context@3.1.4

it's up to you to make yarn workspaces work for your project, we don't handle that

@soletan
Copy link

soletan commented Oct 30, 2020

@brentvatne I see, but I was using npm before and back then running expo install was stating something about having issues to do something right away since I don't use yarn but npm. So what is it? And since all I do is running yarn install and yarn add on a very simple package.json what is it I'm doing wrong here? AFAICT I don't have custom hooks and global scripts or stuff like that involved. yarn is working perfectly in many different projects I'm working on and this expo-based with its 40k of dependencies is not. But yarn is to blame? I don't see this causality. But I'm fine to keep working with npm here.

UPDATE: At least this issue is gone when using npm. So, that's kind of proving your point.

@ide
Copy link
Member

ide commented Oct 30, 2020

@soletan it sounds like you need to debug your yarn.lock and node_modules further. yarn why and setting breakpoints in Yarn itself might be helpful. As Brent mentioned, expo install just calls yarn add with a specific version of the package. If you would like to further isolate what's happening to debug, run just yarn add react-native-safe-area-context@3.1.4 directly and take expo install out of the picture. At any rate, this issue sounds completely independent of expo-yarn-workspaces if I understand correctly.

@soletan
Copy link

soletan commented Oct 30, 2020

Well, as mentioned earlier, I have been switching to yarn before by simply removing node_modules and invoking yarn install. When I was running into that issue with double registration I was following suggestion to run these steps:

  1. remove node_modules
  2. remove yarn.lock
  3. edit package.json to remove react-native-safe-area-context as a dependency
  4. run yarn install
  5. run expo install as given above (which was having that issue right away)

According to that I don't expect that there is much to debug. yarn might be the culprit here and causing some issues instantly. But since it's yarn's stable version 1.22.5 and since I do have tons of issues with expo since upgrading from 37 to 39 to fix deployment issues in Google Play Store for a customer who is unwilling to pay any of the tens to hundreds of hours I'm spending in addition for that for months now, there is little time and motivation left to investigate this issue on behalf of yarn (which is working well in up to 20 different projects I'm using it with) or expo. Right now I'd like to close this project, get rid of it and try a different framework next time which hopefully isn't e.g. having issues when I accidentally use 3.1.8 of a plugin instead of its 3.1.4 which is meant to be basically behaving the same way according to semver.

UPDATE: Just to present the package.json used (with the one dependency to be removed inserted again):

{
  "main": "node_modules/expo/AppEntry.js",
  "scripts": {
    "start": "expo start -c",
    "android": "expo start --android",
    "ios": "expo start --ios",
    "web": "expo start --web",
    "eject": "expo eject",
    "lint": "eslint ."
  },
  "dependencies": {
    "@react-native-community/masked-view": "0.1.10",
    "expo": "^39.0.0",
    "expo-localization": "~9.0.0",
    "native-base": "2.13.14",
    "prop-types": "^15.7.2",
    "react": "16.13.1",
    "react-dom": "16.13.1",
    "react-native": "https://github.com/expo/react-native/archive/sdk-39.0.3.tar.gz",
    "react-native-fit-image": "^1.5.5",
    "react-native-gesture-handler": "~1.8.0",
    "react-native-maps": "0.27.1",
    "react-native-phone-call": "^1.0.9",
    "react-native-reanimated": "~1.13.1",
    "react-native-safe-area-context": "3.1.4",
    "react-native-screens": "~2.12.0",
    "react-navigation": "^4.4.3",
    "react-navigation-drawer": "^2.6.0",
    "react-navigation-stack": "^2.9.0",
    "react-redux": "^7.2.2",
    "redux": "^4.0.5",
    "redux-thunk": "^2.3.0",
    "supercluster": "^7.1.0",
    "expo-location": "~9.0.1",
    "expo-permissions": "~9.3.0"
  },
  "devDependencies": {
    "babel-preset-expo": "^8.3.0",
    "eslint": "^6.8.0",
    "eslint-config-cepharum": "^1.0.11",
    "eslint-config-standard": "^14.1.1",
    "eslint-plugin-import": "^2.20.2",
    "eslint-plugin-node": "^11.1.0",
    "eslint-plugin-promise": "^4.2.1",
    "eslint-plugin-react": "^7.19.0",
    "eslint-plugin-standard": "^4.0.1",
    "expo-vector-icons": "^10.0.1"
  },
  "private": true
}

There are no hooks or similar involved.

@byCedric
Copy link
Member

byCedric commented Jun 30, 2021

Closing, the fix of #11739 (available in expo-yarn-workspaces@1.4.0) should fix this issue. You can see an example of this running on Windows here.

@sadiel06
Copy link

Hola resolv铆 este problema yendo a la pagina oficial de nodejs y descargando el instalador de node en su ultima versi贸n y ejecut谩ndolo.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Projects
None yet
Development

No branches or pull requests