Yarn: Yarn add fails because unrelated module is incompatible

Created on 4 Mar 2017  Â·  14Comments  Â·  Source: yarnpkg/yarn

Edit: Closed. TL;DR: I was using _yarn add dev mochawesome_, when I should have used _yarn add --dev mochawesome_.

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

Bug, (but maybe a misundertanding on my side)

What is the current behavior?
The bug is happening when I try to add a new package. There is a module that is incompatible with the platform and it halts the installation. The thing is, the complaining package is totally unrelated to the module I'm trying to add, or any of my existing packages (I think). Furthermore, when I do a yarn why with the faulty package, it returns that it found nothing.

When I install my wanted package with npm and then run yarn, there is no error.

If the current behavior is a bug, please provide the steps to reproduce.
In this example, the faulty package is inotify

yarn add dev mochawesome
yarn add v0.21.3
[1/4] Resolving packages...
[2/4] Fetching packages...
warning [email protected]: The platform "win32" 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 "win32" is incompatible with this module.
error Found incompatible module
info Visit https://yarnpkg.com/en/docs/cli/add for documentation about this command.

PS C:\project\> yarn why inotify
yarn why v0.21.3
[1/4] Why do we have the module "inotify"...?
[2/4] Initialising dependency graph...
[3/4] Finding dependency...
error We couldn't find a match!
Done in 0.36s.

Here is the output when I install the package with npm and then run yarn

npm install --save-dev mochawesome
project@ C:\project\
`-- [email protected]
  +-- [email protected]
  | `-- [email protected]
  +-- [email protected]
  | +-- [email protected]
  | +-- [email protected]
  | | +-- [email protected]
  | | | +-- [email protected]
  | | | +-- [email protected]
  | | | | +-- [email protected]
  | | | | | `-- [email protected]
  | | | | |   `-- [email protected]
  | | | | `-- [email protected]
  | | | +-- [email protected]
  | | | | `-- [email protected]
  | | | `-- [email protected]
  | | `-- [email protected]
  | `-- [email protected]
  `-- [email protected]

npm WARN optional SKIPPING OPTIONAL DEPENDENCY: fsevents@^1.0.0 (node_modules\chokidar\node_modules\fsevents):
npm WARN notsup SKIPPING OPTIONAL DEPENDENCY: Unsupported platform for [email protected]: wanted {"os":"darwin","arch":"any"} (current: {"os":"win32","arch":"x64"})

yarn
yarn install v0.21.3
[1/4] Resolving packages...
[2/4] Fetching packages...
warning [email protected]: The platform "win32" is incompatible with this module.
info "[email protected]" is an optional dependency and failed compatibility check. Excluding it from installation.
[3/4] Linking dependencies...
[4/4] Building fresh packages...
success Saved lockfile.
Done in 11.33s.

What is the expected behavior?
Run yarn add dev mochawesome successfully

Please mention your node.js, yarn and operating system version.
node v6.9.1
yarn v0.21.3
windows 10, x64

Most helpful comment

It looks like you are running yarn add dev mochawesome instead of yarn add --dev mochawesome

dev is a package which depends on inotify, and inotify only supports Linux according to its package.json

All 14 comments

Interesting — if you do yarn add mochawesome (not --dev) it also works. Only fails when adding to dev dependencies. Also, it fails on OS X with error [email protected]: The platform "darwin" is incompatible with this module. I cannot say much more as I am not trying to work on this myself, just happened to read this issue looking for info on an unrelated problem.

Any workaround for this error?

It looks like you are running yarn add dev mochawesome instead of yarn add --dev mochawesome

dev is a package which depends on inotify, and inotify only supports Linux according to its package.json

Ohh yeah @soutar thanks that solved the issue.

No problem @shahankit, this got me earlier today too :man_facepalming:

But @soutar and co., when I run yarn add dev mochawesome I get the following package.json and no error (!) now:

{
  "name": "churn",
  "version": "1.0.0",
  "main": "index.js",
  "license": "MIT",
  "devDependencies": {
    "mochawesome": "^2.0.4"
  }
}

It looks like maybe the current version of yarn tries to save people from the mistake of not using the proper --dev flag? Interesting that I cannot replicate the earlier bug… I don't recall updating my yarn recently but I suppose I must have done so.

EDIT: see below, this was due to a different version of yarn.

@glebec Interesting. What version of yarn do you have?

Ah! I realize the issue, I'm on a different computer. 😆

This computer had Yarn 0.17.0. Upgrading to current (0.21.3) causes the error. So it looks like Yarn _used to_ support dev as an alias for --dev but removed it later.

Case closed, issue can be closed too IMHO.

Yeah thanks everyone for the clarification. Closing.

I moved every package to devDependencies, and I'm still getting this error.

This problem is a user error. Don't run yarn add dev <package> run yarn add --dev <package>

image

I'm still getting that error. Installing for the first time on Windows 10.

@ejoo Me too, and ... seems the problem was that I invoked Yarn from different operatign systems (Alpine in Docker, + Ubuntu = my host OS), using the same file directory. Then fsevents apparently got built, for the wrong OS, explaining the plattform ... incompatible error, or so I think. Hereafter I'll use the same OS always.

For me, deleting node_modules and reinstalling, solved the problem.

details

I never added dev, instead, now for you and me, it's fsevents, right. And, looking at yarn.lock, the chokidar depends on fsevents:

chokidar@^2.0.0:
  version "2.1.1"
  resolved "https://registry.yarnpkg.com/chokidar/-/chokidar-2.1.1.tgz#adc39ad55a2adf26548bd2afa048f611091f9184"
  dependencies:
    anymatch "^2.0.0"
    async-each "^1.0.1"
    braces "^2.3.2"
    glob-parent "^3.1.0"
    inherits "^2.0.3"
    is-binary-path "^1.0.0"
    is-glob "^4.0.0"
    normalize-path "^3.0.0"
    path-is-absolute "^1.0.0"
    readdirp "^2.2.1"
    upath "^1.1.0"
  optionalDependencies:
    fsevents "^1.2.7"

which is ... what? not compatible with "win32" in your case and not "linux" in my case o. O

Here's my build output:

Attaching to tyd_gulp_1
[3/6] Fetching packages...
[] 0/736(node:10) [DEP0005] DeprecationWarning: Buffer() is deprecated due to security and usability issues. Please use the Buffer.alloc(), Buffer.allocUnsafe(), or Buffer.from() methods instead.
info [email protected]: The platform "linux" is incompatible with this module.     <———— look
info "[email protected]" is an optional dependency and failed compatibility check. Excluding it from installation.
[4/6] Linking dependencies...
...
[5/6] Building fresh packages...
[6/6] Cleaning modules...
Done in 5.92s.

and after this, the Gulp watch task won't work. I was working yesterday, before I upgraded. Anyway, maybe this isn't really Yarn's fault? I'm thinking it's fsevents?

... Turns out that I've been running Yarn both directly on my Ubuntu 16.04, and also in a Docker container with Alpine linux, and I suspect Yarn then built fsnotify for my Ubuntu OS, which then wasn't compatible with Alpine Linux.

I now deleted node_modules and reinstalled — problem gone. And hereafter I'll run Yarn in the same way always, ... no more from different OS:es that use the same file system.

/ End details.

It looks like you are running yarn add dev mochawesome instead of yarn add --dev mochawesome

dev is a package which depends on inotify, and inotify only supports Linux according to its package.json

This worked for me, thank you so much!

Was this page helpful?
0 / 5 - 0 ratings