nodejs / corepack

Zero-runtime-dependency package acting as bridge between Node projects and their package managers
MIT License
2.48k stars 163 forks source link

Cannot bypass "Corepack is about to download" prompt #550

Open moltar opened 3 weeks ago

moltar commented 3 weeks ago

I'm trying to run corepack inside devcontainers, in a postCreateCommand.

I've upgraded corepack to latest:

npm install --yes --global corepack@latest

Then run:

corepack -v && COREPACK_ENABLE_DOWNLOAD_PROMPT=0 corepack enable

The output I get:

0.29.3
! Corepack is about to download https://registry.npmjs.org/pnpm/-/pnpm-9.7.1.tgz
? Do you want to continue? [Y/n] 

I've tried setting CI too, but also does not work.

Any clues?

GDWR commented 3 weeks ago

I just ran into this, although setting that environment variable worked fine for me. I did this in the Dockerfile. Below is an example, and my full Docker below that if useful.

FROM #...

# ...

RUN corepack enable && corepack install --global pnpm@9.8.0
ENV COREPACK_ENABLE_DOWNLOAD_PROMPT=0
Full Dockerfile ```docker FROM mcr.microsoft.com/devcontainers/base:ubuntu-24.04 # Install node # https://nodejs.org/en/download/prebuilt-binaries ARG NODE_VERSION="20.17.0" ARG NODE_CHECKSUM="a24db3dcd151a52e75965dba04cf1b3cd579ff30d6e0af9da1aede4d0f17486b" RUN wget --https-only "https://nodejs.org/dist/v${NODE_VERSION}/node-v${NODE_VERSION}-linux-x64.tar.xz" -O /tmp/node.tar.xz && \ sha256sum /tmp/node.tar.xz | grep "${NODE_CHECKSUM}" && \ tar -C /usr/local -xf /tmp/node.tar.xz --strip-components=1 --exclude="CHANGELOG.md" --exclude="LICENSE" --exclude="README.md" && \ rm /tmp/node.tar.xz && \ corepack enable && \ corepack install --global pnpm@9.8.0 ENV COREPACK_ENABLE_DOWNLOAD_PROMPT=0 ```