Open princesszelda opened 6 years ago
I am hitting this issue, even though the dependency is for source-map@0.5.7
it's pulling in version 0.7.3 which requires node 8.
npm i
works, and installs source-map@0.5.7
yarn
doesn't it bails with the error
error source-map@0.7.3: The engine "node" is incompatible with this module. Expected version ">= 8".
error Found incompatible module
yarn add source-map@0.5.7 --exact
gives the same error
Back to npm
for now I guess.
Version: yarn@1.7.0
One of the packages in your dependency tree is gulp-sourcemaps@1.7.3
, which depends on source-map@0.X
. While 0.5.7
would be a valid resolution, 0.7.3
is just as much. In this particular case, it seems Yarn has opted to install the highest available version possible, rather than use another one from the tree.
Note that even if it works on npm, it's a bit by chance. They don't provide much more guarantees than us in this regard, and no behavior is more right or wrong than the other (for example, if we were to do the opposite, I'm pretty sure someone would open an issue an say "why is 0.X
using 0.5.7
instead of the highest available version?").
That said, there's an easy workaround using Yarn custom resolutions. Add the following to your package.json:
{
"resolutions": {
"gulp-sourcemaps/source-map": "0.5.7"
}
}
This will cause Yarn to force gulp-sourcemaps
to use the exact version you specified, and ignore whatever is its "true" dependency range.
thanks @arcanis for the explanations regarding the no-guarrantees solving the issue switching into npm
and the possible workaround using yarn
.
What happens if in my case I have lot of dependencies depending on source-map
but the error doesn't specify which one is failing.
Here is my npm list source-map --depth=0
├── @babel/cli@7.1.2
├── @babel/core@7.1.2
├── @babel/register@7.0.0
├── @react-pdf/renderer@1.0.0-alpha.18
├── autoprefixer@9.3.0
├── css-loader@0.28.8
├── css-modules-require-hook@4.2.3
├── extract-text-webpack-plugin@3.0.2
├── postcss-loader@2.0.10
├── postcss-nested@4.1.0
├── react-toast-notifications@1.3.1
└── webpack@3.10.0
What I did to find out the problem was coming from gulp-sourcemap
was:
--ignore-engines
(so it gets past the engine validation)yarn.lock
file to see which ranges were resolving to 0.7.3
, which can be done with ctrl-f version "0.7.3"
(that informed me it was 0.X
)0.X
by doing ctrl-f source-map "0.X"
. It brought me directly to gulp-sourcemaps.Probably easier but less instructive and powerful, once you get a tree (still using --ignore-engines
), you can also use yarn why
to have some idea why some packages are in your dependency tree.
Do you want to request a feature or report a bug? Bug
What is the current behavior?
When running command
yarn add source-map@0.5.6 --exact
yarn tries to pull the wrong version of source-map, pulling version 0.7.3 The output is:
If the current behavior is a bug, please provide the steps to reproduce.
This happens inside the kibana repository. When you clone kibana and checkout version 5.6.10, the error occurs. The package.json file lists source-map 0.5.6 and it still tries to pull 0.7.3
This is the content in the package.json file. source-map in devDependencies is listed as 0.5.6
What is the expected behavior?
It should be pulling source-map version 0.5.6
Please mention your node.js, yarn and operating system version. node.js version 6.14.3 yarn version 1.7.0 OS Amazon Linux 2