What could possibly trigger "This package doesn't seem to be present in your lockfile" error? #6200
-
There been at least three reports of the issue before, namely: 2146, 2398, 4856 and other reports on the internet. But none of suggested solutions helped in my case. Unfortunately I can't provide a repro due to the size and complexity of the project, but I hope that I could at least get some advice on where to dig. I have dockerized Nest + PostgreSQL + Vue project with the following settings. # docker-compose.yml
version: "3.9"
networks:
default:
driver: bridge
db:
driver: bridge
volumes:
yarn-cache:
db:
services:
db:
command: ...
restart: always
build:
context: ./../../
dockerfile: ...
environment:
POSTGRES_USER: ...
POSTGRES_HOST: ...
POSTGRES_PASSWORD: ...
POSTGRES_DATABASE: ...
ports:
- ...
networks:
- db
volumes:
- ...
application-prod:
profiles: [...]
build:
context: ../..
dockerfile: .../Dockerfile
target: application
depends_on:
- db
environment:
...
networks:
- db
- default
ports:
- ... # Dockerfile
FROM node:20.11.1-alpine3.19 as base
ENV YARN_GLOBAL_FOLDER /var/yarn
ENV YARN_ENABLE_GLOBAL_CACHE=true
RUN set -xe \
&& mkdir /var/yarn \
&& chown 1000 /var/yarn \
&& corepack enable
WORKDIR /app
FROM base as build-application
ENV CI_JOB_TOKEN=${CI_JOB_TOKEN}
COPY ./package.json /app/package.json
COPY ./yarn.lock /app/yarn.lock
COPY ./.yarnrc.yml /app/.yarnrc.yml
RUN yarn install --immutable
COPY ./ormconfig.ts /app/ormconfig.ts
COPY ./nest-cli.json /app/nest-cli.json
COPY ./src /app/src
COPY ./tsconfig.build.json /app/tsconfig.build.json
COPY ./tsconfig.json /app/tsconfig.json
COPY ./vite.config.ts /app/vite.config.ts
RUN set -xe \
&& yarn add [email protected] \
&& yarn build \
&& yarn install --immutable --immutable-cache
FROM base as application
COPY --from=build-application /app/dist /app/dist
COPY --from=build-application /app/node_modules /app/node_modules
COPY --from=build-application /app/package.json /app/package.json
ENV NODE_ENV=production
ENTRYPOINT ["yarn", "prod"] # .yarnrc.yml
nodeLinker: node-modules
npmScopes:
my-scope1:
npmAlwaysAuth: true
npmAuthToken: ${CI_JOB_TOKEN}
npmRegistryServer: https://gitlab.com/api/v4/groups/${MY_GROUP_A_ID}/-/packages/npm/
my-scope2:
npmAlwaysAuth: true
npmAuthToken: ${CI_JOB_TOKEN}
npmRegistryServer: https://gitlab.com/api/v4/projects/${MY_PROJECT_B_ID}/packages/npm/ // package.json
{
"name": "my-application",
"engines": { "node": "20.11.1" },
"packageManager": "[email protected]",
"scripts": {
"build": "nest build",
"prod": "NODE_ENV=production node dist/src/server/main"
},
"dependencies": {
"@ant-design/icons-vue": "6.1.0",
"@apollo/client": "3.9.10",
"@apollo/server": "4.10.2",
"@as-integrations/fastify": "2.1.1",
"@duannx/vue-client-only": "1.0.3",
"@fastify/cookie": "9.3.1",
"@fastify/static": "7.0.2",
"@fontsource/manrope": "^5.0.9",
"@grpc/grpc-js": "1.10.5",
"@intlify/unplugin-vue-i18n": "3.0.1",
"@nestjs/apollo": "12.1.0",
"@nestjs/common": "10.3.7",
"@nestjs/core": "10.3.7",
"@nestjs/cqrs": "10.2.7",
"@nestjs/graphql": "12.1.1",
"@nestjs/jwt": "10.2.0",
"@nestjs/mapped-types": "2.0.5",
"@nestjs/microservices": "10.3.7",
"@nestjs/passport": "10.0.3",
"@nestjs/platform-fastify": "10.3.7",
"@nestjs/typeorm": "10.0.2",
"@nuxt/devalue": "2.0.2",
"@vitejs/plugin-vue": "5.0.4",
"@vue/apollo-composable": "4.0.2",
"@vue/apollo-option": "4.0.0",
"@vueform/multiselect": "2.5.2",
"@vuelidate/core": "^2.0.0",
"@vuelidate/validators": "^2.0.0",
"@vueuse/router": "^10.7.2",
"ant-design-vue": "3.2.2",
"bcrypt": "5.1.1",
"bignumber.js": "^9.1.1",
"class-transformer": "0.5.1",
"class-validator": "0.13.2",
"cookie": "^0.5.0",
"cross-env": "7.0.3",
"date-fns": "2.29.1",
"fastify": "4.26.2",
"fastify-plugin": "4.5.1",
"fastify-raw-body": "4.3.0",
"graphql": "16.8.1",
"graphql-tag": "2.12.6",
"jsonwebtoken": "^9.0.2",
"maska": "2.1.10",
"nestjs-console": "9.0.0",
"nestjs-pino": "4.0.0",
"otplib": "12.0.1",
"oxide.ts": "^1.0.0",
"passport": "0.7.0",
"passport-custom": "1.1.1",
"pg": "8.11.4",
"pinia": "2.0.23",
"pino": "8.11.0",
"pino-http": "8.3.3",
"pino-pretty": "9.1.1",
"pluralize": "8.0.0",
"primevue": "3.44.0",
"qrcode": "1.5.3",
"reflect-metadata": "0.2.2",
"remove-attr": "^0.0.13",
"rxjs": "7.8.1",
"sanitize-html": "^2.8.1",
"storybook": "7.3.1",
"trezor-address-validator": "0.4.4",
"tsconfig-paths": "4.2.0",
"typeorm": "0.3.20",
"uuid": "9.0.0",
"vite": "5.2.7",
"vue": "3.3.4",
"vue-apollo": "3.1.2",
"vue-i18n": "^9.4.0",
"vue-router": "4.1.6",
"vue3-cookies": "1.0.6",
"zxcvbn": "4.4.2"
}
} And whenever I run:
We don't use workspaces in the project, I definitely run It all started after my attempt to update Yarn from version 1 to 4. Any assistance is appreciated. 🙏 |
Beta Was this translation helpful? Give feedback.
Replies: 2 comments
-
You need to copy the lockfile to the FROM base as application
COPY --from=build-application /app/dist /app/dist
COPY --from=build-application /app/node_modules /app/node_modules
COPY --from=build-application /app/package.json /app/package.json
+ COPY --from=build-application /app/yarn.lock /app/yarn.lock
+ RUN yarn workspaces focus --production
ENV NODE_ENV=production
ENTRYPOINT ["yarn", "prod"] |
Beta Was this translation helpful? Give feedback.
-
@clemyan thanks for pointing this out. To sum up the steps it took to make everything work:
With Yarn v1 setup our idea was to build everything in Anyway, we eventually succeeded, so thanks again for the help and I hope the thread will help someone in the future. ) |
Beta Was this translation helpful? Give feedback.
@clemyan thanks for pointing this out. To sum up the steps it took to make everything work:
yarn.lock
it was also necessary to copy.yarnrc.yml
file and.yarn
folder as it seems now Yarn checks for packages integrity even when I assume that all packages are already downloaded, checked, built and stored in node_modules.CI_JOB_TOKEN
inapplication
container also become mandatory, cause without token it has no access to private npm registries.