sharp icon indicating copy to clipboard operation
sharp copied to clipboard

process.env.npm_package_engines_node is undefined in yarn 2.X

Open hyperparabolic opened this issue 6 years ago • 5 comments

Honestly, I'm unsure if this is a yarn 2.X issue, or an issue here, but here's what I'm seeing:

sharp-v0.26.1 added this semver check snippet for checking the current npm version:

    if (!semver.satisfies(process.versions.node, process.env.npm_package_engines_node)) {
      throw new Error(`Expected Node.js version ${process.env.npm_package_engines_node} but found ${process.versions.node}`);
    }

https://github.com/lovell/sharp/blob/master/install/libvips.js#L83

Yarn v1.22.4 works perfectly with this and installs with no issues:

mkdir yarn1 && cd yarn1
yarn init -y
yarn add sharp

Yarn v2.2.2 runs into issues:

mkdir yarn2 && cd yarn2
yarn init -y
yarn set version berry
yarn add sharp

The error log includes this line:

ERR! sharp Expected Node.js version undefined but found 12.18.3

because npm_package_engines_node is undefined.

The following does work:

npm_package_engines_node=v12.18.3 yarn install

hyperparabolic avatar Sep 23 '20 20:09 hyperparabolic

I'm also following up on the yarn discord to see if I can find any advice there. I'll update this if I find an answer from them or a better workaround.

hyperparabolic avatar Sep 23 '20 20:09 hyperparabolic

This has just been fixed via #2379 and will be in the next release.

lovell avatar Sep 23 '20 20:09 lovell

Oh perfect! Thanks much.

hyperparabolic avatar Sep 23 '20 21:09 hyperparabolic

@lovell I was about to create a PR but noticed this is already fixed 3 weeks ago.

When can we expect sharp 0.26.2 to be released? Thanks!

styfle avatar Oct 12 '20 15:10 styfle

v0.26.2 now available.

lovell avatar Oct 14 '20 18:10 lovell