You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
{{ message }}
Repository navigation
Install Yarn as suggested in official documentation #351
It was working perfectly fine until I decided to update my image and use the provided Yarn instead of my own. Now my project's postinstall script is crashing with Error: Cannot find module '/bin/yarn.js'. If I try to install my own Yarn like above, yours just replace mine and it still doesn't work.
Could you just install Yarn as suggested in the official docs?
I guess the postinstall script has a hard-coded path to yarn? We install yarn in /usr/local/bin which takes precedence over /bin in the PATH variable which is why your version isn't being called.
The chosen installation method was because at the time we added yarn (if I remember this right) the debian package wasn't gpg signed. The installation method we chose is based on Docker's recommendation for Official images: https://github.com/docker-library/official-images#security
Also, and again my memory is a bit fuzzy here, we worked with the some members of the yarn community on this and this installation method was the best option at the time. I think there were some other issues too, like the debian package assumed the node binary was called nodejs and also installed via a debian package.
The PR that landed yarn and the discussion about install method etc. are here fwiw:
Also, the final image size is a concern when installing yarn, this was the most space efficient method.
That's right - The main reason Yarn is installed using the standalone .js file is because it used to be much smaller than the other releases of Yarn. However, in Yarn 0.24.x, we updated the Debian package and tarball to just use the bundled .js file rather than packing the individual files, so the sizes are comparable now. I filed #401 for that, before seeing this issue 😛
the debian package wasn't gpg signed
Debian package is GPG signed if you install it via the package repository. In general, Debian doesn't really GPG sign individual .deb files, only the metadata files for package repositories are signed. You can use debsigs to sign individual .deb files, but Debian doesn't use it out-of-the-box.
. I think there were some other issues too, like the debian package assumed the node binary was called nodejs and also installed via a debian package.
You just need to install it with --no-install-recommends.
You can do the apt-get install --no-install-recommends yarn=$YARN_VERSION but the deb packages have a -1 build part that also needs to be added.
The apt-transport-https can also be skipped if the deb URL is changed to HTTP
I suggest to close this old issue. The Yarn v1 installation script for Docker images based on versions of Node.js <=25 is stable. For upcoming new images based on Node.js >=26, Yarn v1 will no longer be installed (see Yarn v1 Classic bundling).
The original problem was with node:boron (Node.js 6.x) around 10 years ago, on Debian 9 (stretch).
This method continued to be successful whilst there was an incident yarnpkg/yarn#9216 in Jan 2026, where users who were using the method for Ubuntu/Debian from https://classic.yarnpkg.com/en/docs/install (outside of Node.js Docker images) were suddenly unable to verify the download due to an expired key.
The script to install Yarn v1 is dynamically removed when the templates are applied for Node.js >=26 and no Yarn is installed.
The report in #351 (comment) above regarding upgrade difficulties wasn't described in any detail. Yarn v1 is frozen at yarn@1.22.22, released Mar 9, 2024 and this is the version hard-coded into the templates on the assumption that any update would be an unexpected exception.
Based on the above, there seems to be no reason at this time to make any changes to the Yarn v1 installation script for its remaining lifetime.
Activity
chorrell commentedon Mar 30, 2017
I guess the postinstall script has a hard-coded path to yarn? We install yarn in
/usr/local/binwhich takes precedence over/binin the PATH variable which is why your version isn't being called.The chosen installation method was because at the time we added yarn (if I remember this right) the debian package wasn't gpg signed. The installation method we chose is based on Docker's recommendation for Official images: https://github.com/docker-library/official-images#security
Also, and again my memory is a bit fuzzy here, we worked with the some members of the yarn community on this and this installation method was the best option at the time. I think there were some other issues too, like the debian package assumed the node binary was called
nodejsand also installed via a debian package.The PR that landed yarn and the discussion about install method etc. are here fwiw:
yarn(awesome npm alternative) #243karfau commentedon Apr 13, 2017
As a maybe related side note: the docker files for v6.10 (e.g. alpine ) contain the following line:
but running
docker run --rm node:6.10.2-alpine yarn --versionresults in the output
0.22.0This might cause some confusion when people try to find out which version is coming with which docker image.
Starefossen commentedon Apr 13, 2017
Also, the final image size is a concern when installing yarn, this was the most space efficient method.
Daniel15 commentedon May 13, 2017
That's right - The main reason Yarn is installed using the standalone .js file is because it used to be much smaller than the other releases of Yarn. However, in Yarn 0.24.x, we updated the Debian package and tarball to just use the bundled .js file rather than packing the individual files, so the sizes are comparable now. I filed #401 for that, before seeing this issue 😛
Debian package is GPG signed if you install it via the package repository. In general, Debian doesn't really GPG sign individual .deb files, only the metadata files for package repositories are signed. You can use
debsigsto sign individual .deb files, but Debian doesn't use it out-of-the-box.You just need to install it with
--no-install-recommends.Starefossen commentedon May 14, 2017
Thanks for the info @Daniel15! We should revisit whether we should install using the debian repo or continue using the tarball as we do today.
pesho commentedon May 14, 2017
@Starefossen we do not use the tarball today.
nschonni commentedon Aug 4, 2018
Was playing with this and it looks like this would be what is required for the minimum
You can do the
apt-get install --no-install-recommends yarn=$YARN_VERSIONbut the deb packages have a-1build part that also needs to be added.The
apt-transport-httpscan also be skipped if the deb URL is changed to HTTPnschonni commentedon Aug 4, 2018
Alpine 3.6+ can also do the install now with
apk add yarnhttps://yarnpkg.com/en/docs/install#alpine-stablegeoidesic commentedon Jul 26, 2022
The way this has been installed makes it difficult to upgrade yarn
SimenB commentedon Jul 27, 2022
Shouldn't be, instructions in https://yarnpkg.com/getting-started/install remain valid afaik
MikeMcC399 commentedon Apr 13, 2026
I suggest to close this old issue. The Yarn v1 installation script for Docker images based on versions of Node.js <=25 is stable. For upcoming new images based on Node.js >=26, Yarn v1 will no longer be installed (see Yarn v1 Classic bundling).
The original problem was with
node:boron(Node.js 6.x) around 10 years ago, on Debian 9 (stretch).With
node:6.17.1Yarn 1.15.2 is installed to
/usr/local/bin/yarnThe frozen Yarn v1 documentation on https://classic.yarnpkg.com/en/docs/install describes either:
npm install --global yarn # genericallyor
apt install yarn # for Ubuntu / Debian (after environment setup)or
apk add yarn # for AlpineThe Yarn v1 download script embedded in the templates, for example in Dockerfile-debian.template, downloads from https://yarnpkg.com/downloads, using a Yarn tarball on the advice of the Yarn v1 team.
This method continued to be successful whilst there was an incident yarnpkg/yarn#9216 in Jan 2026, where users who were using the method for Ubuntu/Debian from https://classic.yarnpkg.com/en/docs/install (outside of Node.js Docker images) were suddenly unable to verify the download due to an expired key.
The script to install Yarn v1 is dynamically removed when the templates are applied for Node.js >=26 and no Yarn is installed.
The report in #351 (comment) above regarding upgrade difficulties wasn't described in any detail. Yarn v1 is frozen at yarn@1.22.22, released Mar 9, 2024 and this is the version hard-coded into the templates on the assumption that any update would be an unexpected exception.
Based on the above, there seems to be no reason at this time to make any changes to the Yarn v1 installation script for its remaining lifetime.