Yarn: Yarn insists on installing platform specific optional dependencies

Created on 12 Jan 2017  路  3Comments  路  Source: yarnpkg/yarn

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

A bug.

What is the current behavior?

I'm trying to add the etcher-image-write module, which contains a Windows specific optional dependency:

  ...
  "optionalDependencies": {
    "diskpart": "^1.0.0"
  },
  ...

The diskpart module declares in its package.json that can only be installed on Windows:

  ..
  "os": [
    "win32"
  ],
  ..

However I get the following output when trying to add etcher-image-write:

$ yarn add etcher-image-write
yarn add v0.19.0
info No lockfile found.
warning npm-shrinkwrap.json found. This will not be updated or respected. See https://yarnpkg.com/en/docs/migrating-from-npm for more information.
[1/4] 馃攳  Resolving packages...
warning [email protected]: this package is no longer updated or maintained
warning [email protected]: electron-prebuilt has been renamed to electron. For more details, see http://electron.atom.io/blog/2016/08/16/npm-install-electron
warning file-tail > [email protected]: this package is no longer updated or maintained
warning electron-builder > progress-stream > through2 > xtend > [email protected]:
warning electron-packager > asar > mksnapshot > request > [email protected]: use uuid module instead
[2/4] 馃殮  Fetching packages...
warning [email protected]: The platform "darwin" is incompatible with this module.
info "[email protected]" is an optional dependency and failed compatibility check. Excluding it from installation.
warning [email protected]: The platform "darwin" 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 "darwin" is incompatible with this module.
error Found incompatible module
info Visit https://yarnpkg.com/en/docs/cli/add for documentation about this command.

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

yarn add etcher-image-write

What is the expected behavior?

Since diskpart is an optional dependency of etcher-image-write, Yarn should not throw an error if there is a platform mismatch, and simply omit it, like npm.

Please mention your node.js, yarn and operating system version.

  • NodeJS: v6.1.0
  • Yarn: v0.19.0
  • OS: macOS Sierra 10.12.2
cat-bug

All 3 comments

Hm, wait. This is only happens when I run yarn add etcher-image-write from https://github.com/resin-io/etcher, otherwise it installs just fine, which is weird.

Okay, I'll rewrite the issue description here, so the original message doesn't get lost:

We're looking forward to move to Yarn for https://github.com/resin-io/etcher. Here's what I get if I clone the repo and run yarn install on it:

$ git clone https://github.com/resin-io/etcher
$ yarn install
yarn install v0.19.0
info No lockfile found.
warning npm-shrinkwrap.json found. This will not be updated or respected. See https://yarnpkg.com/en/docs/migrating-from-npm for more information.
[1/4] 馃攳  Resolving packages...
warning [email protected]: this package is no longer updated or maintained
warning [email protected]: electron-prebuilt has been renamed to electron. For more details, see http://electron.atom.io/blog/2016/08/16/npm-install-electron
warning file-tail > [email protected]: this package is no longer updated or maintained
warning etcher-image-write > progress-stream > through2 > xtend > [email protected]:
warning electron-packager > asar > mksnapshot > request > [email protected]: use uuid module instead
[2/4] 馃殮  Fetching packages...
warning [email protected]: The platform "darwin" is incompatible with this module.
info "[email protected]" is an optional dependency and failed compatibility check. Excluding it from installation.
warning [email protected]: The platform "darwin" 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 "darwin" is incompatible with this module.
error Found incompatible module
info Visit https://yarnpkg.com/en/docs/cli/install for documentation about this command.

I originally though the issue was related to etcher-image-write, since doing yarn add etcher-image-write on etcher/ yield the same results, but the issue seems to come from removedrive.

This module is an optional dependency of Etcher itself:

  ...
  "optionalDependencies": {
    "elevator": "^2.1.0",
    "removedrive": "^1.1.1"
  },
  ..

And its a Windows only package:

  ...
  "os": [
    "win32"
  ],
  ...

The same argument from the original issue holds:

Since removedrive is an optional dependency of etcher, Yarn should not throw an error if there is a platform mismatch, and simply omit it, like npm.

I'm having this issue as well, with the following:
https://github.com/alykoshin/winston-winlog3
depends on a windows-only module:
https://github.com/alykoshin/node-windows

we have the following in our package.json

  "optionalDependencies": {
    "winston-winlog3": "^1.0.6"
  },

error:
error [email protected]: The platform "darwin" is incompatible with this module.

Was this page helpful?
0 / 5 - 0 ratings