Skip to content

Error when using yarn install on multi-platforms with optionalDependencies #1435

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’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Closed
pierrefourgeaud opened this issue Oct 25, 2016 · 5 comments

Comments

@pierrefourgeaud
Copy link

Do you want to request a feature or report a bug?

Bug.

What is the current behavior?

I get an error while using yarn install instead of just ignoring the dependency.

If the current behavior is a bug, please provide the steps to reproduce.

Here is an excerpt of my package.json:

{
  // ...
  "dependencies": {
    // ...
  },
  "devDependencies": {
    // ...
  },
  "optionalDependencies": {
    "appdmg": "^0.4.5",
    // ...
  },
  // ...
}

Then :
yarn install

Result:

yarn install v0.16.1
info No lockfile found.
warning [email protected]: No license field
[1/4] Resolving packages...
warning electron-prebuilt > electron-download > nugget > progress-stream > through2 > xtend > [email protected]: 
[2/4] Fetching packages...
warning [email protected]: The platform "linux" is incompatible with this module.
info "[email protected]" is an optional dependency and failed compatibility check. Excluding it from installation.
error [email protected]: The platform "linux" is incompatible with this module.
error Found incompatible module
info Visit https://yarnpkg.com/en/docs/cli/install for documentation about this command.

As a comment, it is important to underline that appdmg has actually a dependency named ds-store that has one named macos-alias.

What is the expected behavior?
Yarn should completely ignore appdmg, therefore any dependency related to it.

Please mention your node.js, yarn and operating system version.
Node: 6.5.0
OS: Linux Ubuntu 16.04 (work on OSX 10.10.5 since appdmg is for Darwin).

@pierrefourgeaud
Copy link
Author

I actually see two solutions to that issue. (I did two commit, preferring the second solution, I did a pull request)

In the file src/package-request.js, find():

Solution 1: Simply mark all dependencies of an optionalDependency as optional.
pierrefourgeaud@f6f159d

Solution 2: Check if the optional dependency works with the os, if it doesn't just pass it.
pierrefourgeaud@6e6b613
#1438

@pierrefourgeaud
Copy link
Author

This is still an issue, the fix provided by @mvestergaard doesn't affect this one. Here is a screenshot of my last try:
windows-yarn-error

@mvestergaard
Copy link
Contributor

I think that is caused by the same as #2142

@chiedo
Copy link

chiedo commented Jan 4, 2017

I think I've figured out a way around this

yarn install --ignore-platform seems to do the trick for me though I am unsure if there will be any side effects from using that.

@anaisbetts
Copy link

This is a big problem for Electron apps, it means that any yarn.lock you generate is probably wrong and only works on that platform /cc vercel/hyper#1360

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

No branches or pull requests

5 participants