Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Using node LTS leads to error during docker run #2095

Open
shuo-move opened this issue May 31, 2024 · 3 comments
Open

Using node LTS leads to error during docker run #2095

shuo-move opened this issue May 31, 2024 · 3 comments

Comments

@shuo-move
Copy link

Version

v20.14.0

Platform

macOS

Subsystem

No response

What steps will reproduce the bug?

Dockerfile:
FROM node:lts as base
...
RUN yarn install --immutable --immutable-cache
...
RUN yarn build
...
CMD yarn start

repro steps:

  1. run command docker build -t test-image . and image should be built without error
  2. run command docker run -p 3000:3000 test-image and it leads to error
error This project's package.json defines "packageManager": "[email protected]". However the current global version of Yarn is 1.22.22.

Presence of the "packageManager" field indicates that the project is meant to be used with Corepack, a tool included by default with all official Node.js distributions starting from 16.9 and 14.19.
Corepack must currently be enabled by running corepack enable in your terminal. For more information, check out https://yarnpkg.com/corepack.

How often does it reproduce? Is there a required condition?

It is 100% reproducible with node v20.14.0 (latest LTS). After pinned node version to 18.20.3, the issue is gone.

I've tried lower version of node 20 like 20.9.0 and it has the same issue.

FROM node:18.20.3 as base

What is the expected behavior? Why is that the expected behavior?

The docker run command should not error out.

What do you see instead?

running command docker run -p 3000:3000 test-image leads to error:

error This project's package.json defines "packageManager": "[email protected]". However the current global version of Yarn is 1.22.22.

Presence of the "packageManager" field indicates that the project is meant to be used with Corepack, a tool included by default with all official Node.js distributions starting from 16.9 and 14.19.
Corepack must currently be enabled by running corepack enable in your terminal. For more information, check out https://yarnpkg.com/corepack.

Additional information

No response

@marco-ippolito
Copy link
Member

marco-ippolito commented Jun 1, 2024

"packageManager": "[email protected]"
Looks like you are using a corepack feature without corepack being enabled.
cc @nodejs/corepack

@richardlau
Copy link
Member

error This project's package.json defines "packageManager": "[email protected]". However the current global version of Yarn is 1.22.22.

Presence of the "packageManager" field indicates that the project is meant to be used with Corepack, a tool included by default with all official Node.js distributions starting from 16.9 and 14.19.
Corepack must currently be enabled by running corepack enable in your terminal. For more information, check out https://yarnpkg.com/corepack.

This message is from yarn 1.22.20 and later:

A message will be displayed when Yarn 1.22 notices that the local project has a package.json file referencing a non-1.x Yarn release via the packageManager field. The message will explain that the project is intended to be used with Corepack.

It looks like the Docker images for Node.js 20 include yarn 1.22.22 while the image for Node.js 18 includes an older yarn 1.22.19 (i.e. before the behaviour was changed).

I'll move this issue to https://github.com/nodejs/docker-node.

@richardlau richardlau transferred this issue from nodejs/node Jun 1, 2024
@LaurentGoderre
Copy link
Member

This error message is by design, it tells you that the package file is from a newer version of yarn. You would need to update yarn in your image.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

4 participants