Open Joelasaur opened 1 year ago
I am now getting this exact same error in another repository that is NOT a monorepo, so I don't think this has anything to do with yarn workspaces.
I am getting the same error for workspaces. Yarn 3. Package.json and yarn.lock are copied together with yarnrc
I met the same problem, how to solve it?
How to solve it? It is very frustrating problem.
I encountered this error with Yarn v3.6.1 using a Dockerfile that looked as follows:
FROM node:20.2.0-alpine as frontend-build
ENV NODE_ENV production
RUN mkdir -p /tmp/frontend-build
COPY .babelrc rollup.config.mjs gulpfile.mjs package.json tailwind.config.mjs .yarnrc.yml yarn.lock ./
COPY .yarn .yarn
COPY via/static /via/static
RUN yarn install --immutable
RUN yarn build
I was able to workaround the issue by copying the files into a sub-directory of root (/tmp/frontend-build
) and running yarn install
there:
FROM node:20.2.0-alpine as frontend-build
ENV NODE_ENV production
RUN mkdir -p /tmp/frontend-build
COPY .babelrc rollup.config.mjs gulpfile.mjs package.json tailwind.config.mjs .yarnrc.yml yarn.lock /tmp/frontend-build
COPY .yarn /tmp/frontend-build/.yarn
COPY via/static /tmp/frontend-build/via/static
WORKDIR /tmp/frontend-build
RUN yarn install --immutable
RUN yarn build
try to delete yarn.lock
and create an empty yarn.lock
and run the command again
Creating a new yarn.lock
resolved the problem!!
Creating an empty yarn.lock
file is not a practical solution for all cases. For instance, it breaks NextJS (yarn create next-app
) installation in the middle and I have to manually create the lock file and then issue yarn install
to complete the installation. So in my heck opinion, the ultimate solution to this issue is:
Enable corepack if you already didn't:
corepack enable
Change corepack's good known repo for the yarn from v1
to stable
:
corepack install -g yarn@stable
No need for yarn set version berry
from now on and therefore no package.json
nor .yarnrc
files will be generated in the upper directories of your project.
Describe the bug
I'm seeing this issue https://github.com/yarnpkg/berry/issues/2212 happening while building a docker image. Opening a new issue thread because the solution in the resolved issue was related to a nested yarn project, but this is happening in the root directory of a docker container, which doesn't make any sense to me.
Here is a simplified version of the dockerfile:
Project folder structure (this is a monorepo with multiple workspaces): Root
The package.json is located in a subdirectory workspace, but you can see we are copying it to the root of the image via
Here is the error:
This option seems to apply to me:
but to be honest I'm not sure what it means or where to start debugging this.
Thank you for reading!
To reproduce
My
apps/my-app/package.json
file looks like this:Then
packages/myPackage/package.json
looks like this:Environment
Additional context
No response