berry
berry copied to clipboard
[Bug?]: Missing package: typescript@patch:typescript@npm
Self-service
- [ ] I'd be willing to implement a fix
Describe the bug
a very simple packge.json with
...
"scripts": {
"build": "tsc"
},
"dependencies": {
"@types/node": "22.5.2",
"tslib": "2.7.0",
"typescript": "5.5.4"
},
"packageManager": "[email protected]"
....
and a dockerfile
FROM node:20-alpine AS dependencies
RUN corepack enable
WORKDIR /app
COPY package.json ./
COPY yarn.lock ./
RUN yarn --immutable
FROM node:20-alpine AS builder
RUN corepack enable
WORKDIR /app
COPY --from=dependencies /app/package.json ./
COPY --from=dependencies /app/.pnp.cjs ./
COPY --from=dependencies /app/.yarn ./.yarn
COPY --from=dependencies /app/yarn.lock ./
COPY ./src ./src
RUN yarn build
FROM node:20-alpine AS runner
RUN corepack enable
WORKDIR /app
COPY --from=builder /app/build ./
COPY --from=dependencies /app/.pnp.cjs ./
COPY --from=dependencies /app/.yarn ./.yarn
ENTRYPOINT ["node", "src/testCode.js"]
fails with error
> [builder 9/9] RUN yarn build:
1.157 ! Corepack is about to download https://repo.yarnpkg.com/4.4.1/packages/yarnpkg-cli/bin/yarn.js
3.298 /app/.pnp.cjs:5676
3.298 throw firstError;
3.298 ^
3.298
3.298 Error: Required package missing from disk. If you keep your packages inside your repository then restarting the Node process may be enough. Otherwise, try to run an install first.
3.298
3.298 Missing package: typescript@patch:typescript@npm%3A5.5.4#optional!builtin<compat/typescript>::version=5.5.4&hash=379a07
3.298 Expected package location: /root/.yarn/berry/cache/typescript-patch-fe43cd9db9-10c0.zip/node_modules/typescript/
3.298
3.298 at require$$0.Module._resolveFilename (/app/.pnp.cjs:5675:13)
3.298 at Module._load (node:internal/modules/cjs/loader:1051:27)
3.298 at require$$0.Module._load (/app/.pnp.cjs:5566:31)
3.298 at Function.executeUserEntryPoint [as runMain] (node:internal/modules/run_main:174:12)
3.298 at node:internal/main/run_main_module:28:49
yarn build
outside docker works fine !
To reproduce
Clone https://github.com/uchar/yarnbugs/tree/multistage_typescript_patch_error move to branch multistage_typescript_patch_error
Then run
yarn
docker build -t yarn_bug .
you will see the error
4.967 Error: Required package missing from disk. If you keep your packages inside your repository then restarting the Node process may be enough. Otherwise, try to run an install first.
4.967
4.967 Missing package: typescript@patch:typescript
Environment
System:
OS: Linux 5.15 Alpine Linux
CPU: (16) x64 AMD Ryzen 7 5800H with Radeon Graphics
Binaries:
Node: 20.17.0 - /tmp/xfs-19d7b165/node
Yarn: 4.4.1 - /tmp/xfs-19d7b165/yarn
npm: 10.8.2 - /usr/local/bin/npm
Additional context
No response