Yarn: Yarn fails on transitive optional dependencies that aren't compatible with the current OS

Created on 6 Oct 2016  路  6Comments  路  Source: yarnpkg/yarn

Yarn handles this correctly for direct dependencies (ie. dependencies in the package.json of the app you're running Yarn on), but not for transitive dependencies (ie. dependencies of _those_ dependencies).

Example package.json to repro on Windows:

{
  "name": "hello",
  "version": "0.0.1",
  "dependencies": {
    "chokidar": "1.6.0"
  }
}

Example package.json to repro on Linux or Mac OS X:

{
  "name": "hello",
  "version": "0.0.1",
  "dependencies": {
    "@daniel15/win-test-2": "0.0.1"
  }
}

chokidar has an optional dependency on fsevent, which only works on Mac OS. Similarly, @daniel15/win-test-2 has an optional dependency on @daniel15/win-test which only works on Windows.

Output from npm install:

npm WARN optional Skipping failed optional dependency /chokidar/fsevents:
npm WARN notsup Not compatible with your operating system or architecture: [email protected]

Output from yarn (Windows):

error [email protected]: The platform "win32" is incompatible with this module.
error Found incompatible module
    at MessageError (c:\src\yarn\lib\errors.js:9:1)
    at PackageCompatibility.check (c:\src\yarn\lib\package-compatibility.js:166:13)
    at PackageCompatibility.init (c:\src\yarn\lib\package-compatibility.js:173:12)
    at c:\src\yarn\lib\cli\commands\install.js:312:38
    at next (native)
    at step (c:\src\yarn\node_modules\babel-runtime\helpers\asyncToGenerator.js:17:30)
    at c:\src\yarn\node_modules\babel-runtime\helpers\asyncToGenerator.js:28:20

Output from Yarn (Debian Linux):

error @daniel15/[email protected]: The platform "linux" is incompatible with this module.
error Found incompatible module
    at MessageError (/home/daniel/src/yarn/lib-legacy/errors.js:9:1)
    at PackageCompatibility.check (/home/daniel/src/yarn/lib-legacy/package-compatibility.js:170:13)
    at PackageCompatibility.init (/home/daniel/src/yarn/lib-legacy/package-compatibility.js:177:12)
    at /home/daniel/src/yarn/lib-legacy/cli/commands/install.js:326:38
    at next (native)
    at step (/home/daniel/src/yarn/node_modules/babel-runtime/helpers/asyncToGenerator.js:17:30)
    at /home/daniel/src/yarn/node_modules/babel-runtime/helpers/asyncToGenerator.js:28:20
    at run (/home/daniel/src/yarn/node_modules/core-js/library/modules/es6.promise.js:87:22)
    at /home/daniel/src/yarn/node_modules/core-js/library/modules/es6.promise.js:100:28
    at flush (/home/daniel/src/yarn/node_modules/core-js/library/modules/_microtask.js:18:9)

This blocks installation of create-react-app, browserify and webpack on Windows (among other things) as they all have a dependency on either chokidar or fsevents

cat-bug

All 6 comments

@kittens - Any ideas if this is an easy fix? I think it's blocking for launch given Windows and Linux users currently can't install packages that have a transitive dependency on fsevents.

Looks like this regressed at some point 馃槩 #1285

I think this change fixed it half-way, fixing #1285 should bring it to completion. @kittens can you please take a look?

Ran into this issue today with winston-winlog3 in optionalDependencies on macOS.

hello i am using windows 10 and i am working with Jhipster ( with Angular1 ans Postgres as SGDB) and i have have same bug
and here is my package.json file
{ "name": "j-hipster-registry", "version": "0.0.0", "description": "Description for JHipsterRegistry", "private": true, "cacheDirectories": [ "node_modules" ], "dependencies": { "@angular/common": "4.0.0", "@angular/compiler": "4.0.0", "@angular/core": "4.0.0", "@angular/forms": "4.0.0", "@angular/http": "4.0.0", "@angular/platform-browser": "4.0.0", "@angular/platform-browser-dynamic": "4.0.0", "@angular/router": "4.0.0", "@ng-bootstrap/ng-bootstrap": "1.0.0-alpha.23", "angular2-cookie": "1.2.6", "angular2-infinite-scroll": "0.3.4", "bootstrap": "4.0.0-alpha.6", "core-js": "2.4.1", "font-awesome": "4.7.0", "gulp": "^3.9.1", "jquery": "3.2.1", "ng-jhipster": "0.1.12", "ng2-webstorage": "1.6.2", "reflect-metadata": "0.1.10", "rxjs": "5.3.0", "swagger-ui": "2.2.10", "tether": "1.4.0", "zone.js": "0.8.5" }, "devDependencies": { "@angular/cli": "1.0.0", "@angular/compiler-cli": "4.0.0", "@types/jasmine": "2.5.47", "@types/node": "7.0.12", "add-asset-html-webpack-plugin": "1.0.2", "angular2-template-loader": "0.6.2", "awesome-typescript-loader": "3.1.2", "browser-sync": "2.18.8", "browser-sync-webpack-plugin": "1.1.4", "codelyzer": "2.1.1", "copy-webpack-plugin": "4.0.0", "css-loader": "0.28.0", "del": "2.2.2", "event-stream": "3.3.4", "exports-loader": "0.6.4", "extract-text-webpack-plugin": "2.1.0", "file-loader": "0.11.1", "generator-jhipster": "4.3.0", "html-loader": "0.4.5", "html-webpack-plugin": "2.28.0", "jasmine-core": "2.5.2", "karma": "1.6.0", "karma-chrome-launcher": "2.0.0", "karma-coverage": "1.1.1", "karma-intl-shim": "1.0.3", "karma-jasmine": "1.1.0", "karma-junit-reporter": "1.2.0", "karma-notify-reporter": "1.0.1", "karma-phantomjs-launcher": "1.0.4", "karma-remap-istanbul": "0.6.0", "karma-sourcemap-loader": "0.3.7", "karma-webpack": "2.0.3", "lazypipe": "1.0.1", "lodash": "4.17.4", "map-stream": "0.0.7", "phantomjs-prebuilt": "2.1.14", "proxy-middleware": "0.15.0", "rimraf": "2.6.1", "run-sequence": "1.2.2", "sourcemap-istanbul-instrumenter-loader": "0.2.0", "string-replace-webpack-plugin": "0.1.3", "style-loader": "0.16.1", "to-string-loader": "1.1.5", "tslint": "4.5.1", "tslint-loader": "3.5.2", "typescript": "2.2.2", "webpack": "2.3.3", "webpack-dev-server": "2.4.2", "webpack-merge": "4.1.0", "webpack-notifier": "1.5.0", "webpack-visualizer-plugin": "0.1.11", "write-file-webpack-plugin": "3.4.2", "xml2js": "0.4.17", "sass-loader": "5.0.1", "node-sass": "4.5.0", "postcss-loader": "1.3.0", "yargs": "6.6.0" }, "engines": { "node": ">=6.9.0" }, "scripts": { "lint": "tslint 'src/main/webapp/app/**/*.ts' --force", "lint:fix": "tslint 'src/main/webapp/app/**/*.ts' --fix --force", "tsc": "tsc", "tsc:w": "tsc -w", "ngc": "ngc -p tsconfig-aot.json", "cleanup": "rimraf target/", "start": "yarn run webpack:dev", "webpack:build": "yarn run ngc && webpack --config webpack/webpack.vendor.js && webpack --config webpack/webpack.dev.js", "webpack:build:dev": "webpack --config webpack/webpack.dev.js", "webpack:build:vendor": "webpack --config webpack/webpack.vendor.js", "webpack:dev": "webpack-dev-server --config webpack/webpack.dev.js --progress --inline --hot --profile --port=9060", "webpack:prod": "yarn run ngc && yarn run test && webpack -p --config webpack/webpack.vendor.js && webpack -p --config webpack/webpack.prod.js", "test": "yarn run lint && karma start src/test/javascript/karma.conf.js", "test:watch": "karma start --watch", "postinstall": "yarn run webpack:build" } }

and this is what the error shows

yarn install v0.19.1 [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...
thnks 4 help

Was this properly resolved? I'm interested in switching my team's process to yarn, but I'm running into similar issues here.

I'm attempting to setup workspaces, because we have a monrepo setup, and the source registry is a private registry in Azure DevOps. The problematic package is our own native node module in the workspace (it has "os": [ "darwin" ] in the package.json). We have another workspace package that optionally includes it ("optionalDependencies": { "our-native-package": "1.0.0" }). Yarn fails to install with an error saying our-native-package is incompatible.

Was this page helpful?
0 / 5 - 0 ratings