docker-node icon indicating copy to clipboard operation
docker-node copied to clipboard

Decision about yarn in version 21 of Node

Open LaurentGoderre opened this issue 1 year ago • 12 comments

The decision to include yarn into the image has had some mixed reaction and the departure from staying with the default installation of the Node package leads to a lot of disagreement.

Node 21 was just released so we now have the opportunity to not include Yarn by default in this new version and maybe add a variant that has yarn. What do people think?

iMO, this issue should be resolved before adding v21.

LaurentGoderre avatar Oct 17 '23 16:10 LaurentGoderre

There have been a lot of responses to feature requests in this repo along the lines of "we ship what Node.js ships, and nothing more". I believe this stance is very reasonable for the official Node.js images. I also think that implies yarn should not be shipped, or it would be inconsistent.

As discussed in #777 and other issues, package managers (and that includes npm) contribute a lot to the image size especially for Alpine-based images. If we can't decide on a variant for multi-stage builds that ships entirely without any package managers, perhaps we can find common ground by at least eliminating yarn.

One could make the argument that a lot of people are using yarn, but then again, a lot of people are using pnpm, and recently maybe bun, and those aren't included.

When defining a custom image, it's really quite simple to add an install command for additional package managers as needed. On the other hand, it can be tricky to remove existing parts of an image without breaking things. As such, I think the default should be an image that includes as little additional stuff as possible.

meyfa avatar Oct 17 '23 17:10 meyfa

I haven't been following what's happening with corepack. If corepack is now on by default in 21, I think it makes it an easier sell that directions on how to use Yarn could be replaced

nschonni avatar Oct 17 '23 17:10 nschonni

I see no reason to hold off on releasing a v21 image on this.

v21 will be EOL in about 9 months anyways (way before e.g. Node 20 which already ships with Yarn), so removing it for newer versions now will just increase maintenance/fragmentation, not lower it. v22 is a better release to consider it as that will turn LTS and stick around for a long time.


And yes, corepack is probably the solution, just as it has been in the numerous other discussions we've had on this. It's still considered experimental, however (also in 21).

image

And I'm also (still) of the opinion we should just not ship a package manager at all if the point is to save on size.


The decision to include yarn into the image has had some mixed reaction and the departure from staying with the default installation of the Node package leads to a lot of disagreement.

Can you point to any recent discussions around this?

SimenB avatar Oct 17 '23 21:10 SimenB

Just to list a few:

https://github.com/nodejs/docker-node/pull/1768 https://github.com/nodejs/docker-node/pull/1245 https://github.com/nodejs/docker-node/issues/1238 https://github.com/nodejs/docker-node/issues/777 https://github.com/nodejs/docker-node/pull/898 https://github.com/nodejs/docker-node/pull/808

LaurentGoderre avatar Oct 18 '23 20:10 LaurentGoderre

Happy to explore the latest one (https://github.com/nodejs/docker-node/pull/1768) - the others are more than 3 years old, so at least to me it doesn't seem to have much momentum/requests behind it.

(this is just my personal opinion, tho)

SimenB avatar Oct 24 '23 22:10 SimenB

It seems especially odd that we’d bundle Yarn 1, when the current version is 4. Especially since Yarn 1.x seems to be abandoned and has issues.

GeoffreyBooth avatar Jan 11 '24 00:01 GeoffreyBooth

I think it's either you bundle the Node docker image with the popular other package managers (pnpm, yarn, etc) or you just keep it only with npm and people can install their own preferred package manager alternative for npm

weyert avatar Jan 30 '24 14:01 weyert

If https://github.com/nodejs/node/pull/51886 lands, what would happen to the Yarn that’s included in the Docker image? Would we just stop including Yarn 1, and /usr/local/bin/yarn would be a symlink to Corepack, the way it is after you run corepack enable? I assume that would be fine, if done as a semver-major change?

cc @aduh95 @nodejs/corepack

GeoffreyBooth avatar Mar 03 '24 22:03 GeoffreyBooth

I've been wanting to remove the preinstalled version and run corepack enable instead for some time, so if it that's kinda what Node itself decides to do in v22, then I think we'd just remove our own manual installation like you outline. 👍

We could probably then add a "core" version or something with just Node (so removing yarn, corepack, npm, npx etc) for those that don't want the "bloat". We've had requests for that for a long time.

SimenB avatar Mar 04 '24 07:03 SimenB

If we change the symlink to point to Corepack, then there would be no version of Yarn included with the image. It would be downloaded on first use.

GeoffreyBooth avatar Mar 04 '24 07:03 GeoffreyBooth

Ah, right! I think that's probably fine. You don't need the package manager unless you're gonna install things, at which point you have internet to download the package manager anyways. If we go with a "core" image as well, we can probably run some command to preinstall, but that's a separate discussion.

SimenB avatar Mar 04 '24 07:03 SimenB

Yarn has been my favorite package manager for a long time and I really appreciate that it comes ready with corepack enable. I've tried to use npm many times but I always find myself dragged to the "peer dependencies" conflict hell along the way. So yeah! A thumbs up for Yarn 👍

monecchi avatar Mar 17 '24 05:03 monecchi