Do you want to request a feature or report a bug?
Bug
What is the current behavior?
yarn errors when a resolution for an optional dependency is specified if run on an incompatable platform.
fsevents is only available on macOS (darwin):
"resolutions": {
"**/fsevents": ">=1.2.4"
}
root@fbcb6ce8bfb9:/# yarn
yarn install v1.12.3
[1/5] Validating package.json...
[2/5] Resolving packages...
[3/5] Fetching packages...
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.
md5-da07f57e7a65200a1ac248dfaf49123e
root@fbcb6ce8bfb9:/# yarn
yarn install v1.12.3
[1/5] Validating package.json...
[2/5] Resolving packages...
[3/5] Fetching packages...
info [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.
info [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.
[4/5] Linking dependencies...
What is the expected behavior?
No incompatibility errors.
Please mention your node.js, yarn and operating system version.
node v9.8.0, yarn 1.12.3, ubuntu 16.04.2 docker image
This sounds familiar... I think there is an open issue for this, but I can't seem to find it.
IIRC yarn adds the resolution as a hard-coded normal dependency _first_ before checking the rest of the deps. Then it finds the optional dep and replaces it with the existing (non-optional) resolution dep.
Is there any update on this? I can help with the PR, what would be the proper solution to this?
I think this is fixed with #7273, right? /cc @kaylie-alexa
This sounds familiar... I think there is an open issue for this, but I can't seem to find it.
Are you thinking of https://github.com/yarnpkg/yarn/issues/2437?
@BYK I can confirm this is still not fixed using yarn v1.17.3
This is happening for me in yarn v1.19.1
Also seeing this on yarn v1.19.2
The problem occurs when transitive dependencies are optional, so this test fails
This is likely the most common usage of resolutions 鈥撀爄f it's a direct dependency, why use resolutions instead of just modifying the version in dependencies?
Workaround is to explicitly define the transitive optional dependency at the root, e.g:
{
"resolutions": {
"**/fsevents": ">=1.2.4"
},
"optionalDependencies": {
"fsevents": "*"
}
}
Then yarn --ignore-optional behaves as expected.
Hi, do we have a solution for this? We are running the same issue for node 12 and fsevents 1.2.9. Works on mac os but incompatible with linux environments.
I can confirm this bug on node 12.16.1, yarn 1.22.4 with fsevents 1.2.9+
For anyone experiencing this issue I have made a script we have been using for months with success. It runs on our CI prior to running yarn install.
sed -ie 's/\"\*\*\/fsevents\": \"^1.2.9\",//g' package.json
START_NUM=$(awk '/fsevents@/{print NR; exit }' yarn.lock)
echo $START_NUM
END_NUM=$(($START_NUM + 7))
echo $END_NUM
sed -i.bak -e $START_NUM','$END_NUM'd' yarn.lock
It may need some tweaks for your specific use case but it has helped us get around the fsevents error on our CI (it isn't an issue locally as we all use Macs)
It will remove the fsevents entry in your package json and yarn lock file.
Most helpful comment
Also seeing this on yarn v1.19.2
7273 Seems to only have fixed the issue for direct optional dependencies
The problem occurs when transitive dependencies are optional, so this test fails
This is likely the most common usage of
resolutions鈥撀爄f it's a direct dependency, why useresolutionsinstead of just modifying the version independencies?Workaround is to explicitly define the transitive optional dependency at the root, e.g:
Then
yarn --ignore-optionalbehaves as expected.