Comments (5)
This is a bit of a hack, but if you want to get around it, you can set the CI
environment variable to true
(see here for alternate variables). I haven't found a way to use command line arguments, or pnpm config files, to change the package manager options, but tricking it into detecting a CI build will skip the prompt.
from pnpm.
yeah, i keep getting this on a clean docker build. idk why.
#13 1.322 ? The modules directory at "/app/node_modules" will be removed and reinstalled from scratch. Proceed? (Y/n) ‣ true
#13 DONE 1.5s
#14 [web development 7/8] RUN pnpm install [email protected]
#14 1.154 ERR_PNPM_UNEXPECTED_STORE Unexpected store location
#14 1.154
#14 1.154 The dependencies at "/app/node_modules" are currently linked from the store at "/home/node/.pnpm-store/v3".
#14 1.154
#14 1.154 pnpm now wants to use the store at "/root/.local/share/pnpm/store/v3" to link dependencies.
#14 1.154
#14 1.154 If you want to use the new store location, reinstall your dependencies with "pnpm install".
#14 1.154
#14 1.154 You may change the global store location by running "pnpm config set store-dir <dir> --global".
#14 1.154 (This error may happen if the node_modules was installed with a different major version of pnpm)
#14 ERROR: process "/bin/sh -c pnpm install [email protected]" did not complete successfully: exit code: 1
------
> [web development 7/8] RUN pnpm install [email protected]:
1.154 ERR_PNPM_UNEXPECTED_STORE Unexpected store location
1.154
1.154 The dependencies at "/app/node_modules" are currently linked from the store at "/home/node/.pnpm-store/v3".
1.154
1.154 pnpm now wants to use the store at "/root/.local/share/pnpm/store/v3" to link dependencies.
1.154
1.154 If you want to use the new store location, reinstall your dependencies with "pnpm install".
1.154
1.154 You may change the global store location by running "pnpm config set store-dir <dir> --global".
1.154 (This error may happen if the node_modules was installed with a different major version of pnpm)
------
failed to solve: process "/bin/sh -c pnpm install [email protected]" did not complete successfully: exit code: 1
make: *** [Makefile:3: build-dev] Error 17
for context, this is my current dockerfile:
FROM node:20-alpine AS base
# mostly inspired from https://github.com/BretFisher/node-docker-good-defaults/blob/main/Dockerfile & https://github.com/remix-run/example-trellix/blob/main/Dockerfile
# Check https://github.com/nodejs/docker-node/tree/b4117f9333da4138b03a546ec926ef50a31506c3#nodealpine to understand why libc6-compat might be needed.
RUN apk add --no-cache libc6-compat
RUN corepack enable && corepack prepare [email protected] --activate
# 1. Install all dependencies including devDependencies
FROM base AS development
# Root user is implicit so you don't have to actually specify it. From https://stackoverflow.com/a/45553149/6141587
# USER root
USER node
# WORKDIR now sets correct permissions if you set USER first so `USER node` has permissions on `/app` directory
WORKDIR /app
# set the store dir to a folder that is not in the project
RUN pnpm config set store-dir ~/.pnpm-store
# Install dependencies based on the preferred package manager
COPY --chown=node:node package.json pnpm-lock.yaml ./
RUN --mount=type=cache,id=pnpm,target=~/.pnpm-store pnpm fetch
ENV NODE_ENV development
ENV NEXT_TELEMETRY_DISABLED 1
# Copied from https://stackoverflow.com/a/69867550/6141587
USER root
# Give /data directory correct permissions otherwise WAL mode won't work. It means you can't have 2 users writing to the database at the same time without this line as *.sqlite-wal & *.sqlite-shm are automatically created & deleted when *.sqlite is busy.
RUN mkdir -p /data && chown -R node:node /data
RUN --mount=type=cache,id=pnpm,target=~/.pnpm-store pnpm install --frozen-lockfile --recursive --prefer-offline
RUN pnpm install [email protected]
COPY --chown=node:node . .
USER node
# 2. Rebuild the source code only when needed
FROM base AS builder
WORKDIR /app
# Inspired by https://github.com/vercel/next.js/discussions/36935
RUN mkdir -p /app/.next/cache && chown -R node:node /app/.next/cache
# Persist the next cache in a volume
VOLUME ["/app/.next/cache"]
COPY --from=development --chown=node:node /app/node_modules ./node_modules
COPY --chown=node:node . .
# This will do the trick, use the corresponding env file for each environment.
COPY --chown=node:node .env* ./
# set to production otherwise it throws error ⚠ You are using a non-standard "NODE_ENV" value in your environment. This creates inconsistencies in the project and is strongly advised against. Read more: https://nextjs.org/docs/messages/non-standard-node-env
ENV NODE_ENV production
ENV NEXT_TELEMETRY_DISABLED 1
RUN pnpm build
# 3. Production image, copy all the files and run next
FROM base AS runner
USER node
WORKDIR /app
EXPOSE 3000
ENV PORT 3000
ENV HOSTNAME 0.0.0.0
ENV NODE_ENV production
ENV NEXT_TELEMETRY_DISABLED 1
COPY --from=builder --chown=node:node /app/.env* ./
COPY --from=builder --chown=node:node /app/public ./public
# Automatically leverage output traces to reduce image size
# https://nextjs.org/docs/advanced-features/output-file-tracing
COPY --from=builder --chown=node:node /app/.next/standalone ./
COPY --from=builder --chown=node:node /app/.next/static ./.next/static
# Move the drizzle directory to the runtime image
COPY --from=builder --chown=node:node /app/src/app/db/migrations ./migrations
# Move the litestream binary to the runtime image from the litestream image
# You can use a specific version of litestream by changing the tag
# COPY --from=litestream/litestream:0.3.13 /usr/local/bin/litestream /usr/local/bin/litestream
COPY --from=litestream/litestream:latest --chown=node:node /usr/local/bin/litestream /usr/local/bin/litestream
COPY --from=builder --chown=node:node /app/litestream.yml /etc/litestream.yml
COPY --from=builder --chown=node:node /app/scripts ./scripts
only faced it after i moved some things around like COPY . .
in development stage.
from pnpm.
I'm facing the same issue, any idea why it's happening?
from pnpm.
I think I have an idea why this happens.
When installing packages from inside the docker container, pnpm sets the storeDir property in the node_modules/.modules.yaml file to an absolute path, in my case it's storeDir: /srv/app/.pnpm-store/v3
But when installing locally it sets it to a local absolute path
storeDir: /home/<user>/<project>/.pnpm-store/v3
I've tried setting the store dir both in .npmrc and the cli to a relative path inside the project, so that the same store is available in the project inside a docker volume but it doesn't work
So pnpm detects that and tries to set it correctly by reinstalling everything.
from pnpm.
But it will still "purge" the modules and reinstall everything right?
Because that's what I'd like to avoid.
from pnpm.
Related Issues (20)
- Add a self upgrade options
- `pnpm up` doesn't update `peerDependencies`
- `pnpm install` without input fails when already node_modules exists HOT 2
- print how to upgrade pnpm when `packageManager` version doesn't match HOT 1
- `package-manager-strict` enforcement in pnpm 9 is a massive headache HOT 42
- Error while running `pnpm run ...` HOT 2
- [Feat/Bug] `pnpm init` does not respect `init.*` options as flags like `npm init --init-*` HOT 3
- PNPM consider Turborepo packages as npm packages HOT 2
- v9 install command upgrades Lockfile in CI environment HOT 1
- "pnpm why" doesn't work properly
- pnpm can create forbidden file name on windows HOT 1
- package peerDependencies are written into the lock file as if they were dependencies. HOT 1
- I cannot update version HOT 3
- `pnpm outdated` is suggesting an *older* version as the latest version
- Can't use pnpm global packages via SSH
- EBUSY: resource busy or locked and EPERM: operation not permitted on windows
- jsonwebtoken package is not compatible
- Missing dev dependencies (or executables) in Dockerfile HOT 1
- add npm "home" command
- The `--cwd` flag is unsupported but does not throw an error
Recommend Projects
-
React
A declarative, efficient, and flexible JavaScript library for building user interfaces.
-
Vue.js
🖖 Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.
-
Typescript
TypeScript is a superset of JavaScript that compiles to clean JavaScript output.
-
TensorFlow
An Open Source Machine Learning Framework for Everyone
-
Django
The Web framework for perfectionists with deadlines.
-
Laravel
A PHP framework for web artisans
-
D3
Bring data to life with SVG, Canvas and HTML. 📊📈🎉
-
Recommend Topics
-
javascript
JavaScript (JS) is a lightweight interpreted programming language with first-class functions.
-
web
Some thing interesting about web. New door for the world.
-
server
A server is a program made to process requests and deliver data to clients.
-
Machine learning
Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.
-
Visualization
Some thing interesting about visualization, use data art
-
Game
Some thing interesting about game, make everyone happy.
Recommend Org
-
Facebook
We are working to build community through open source technology. NB: members must have two-factor auth.
-
Microsoft
Open source projects and samples from Microsoft.
-
Google
Google ❤️ Open Source for everyone.
-
Alibaba
Alibaba Open Source for everyone
-
D3
Data-Driven Documents codes.
-
Tencent
China tencent open source team.
from pnpm.