corepack icon indicating copy to clipboard operation
corepack copied to clipboard

corepack use does not load COREPACK_NPM_REGISTRY from .corepack.env

Open Gadzy opened this issue 4 months ago • 5 comments

PROBLEM

corepack use does not load COREPACK_NPM_REGISTRY from .corepack.env

CONFIGURATION

  • macOS v15.6.1
  • NodeJS v22.19.0
  • corepack v0.34.0

DESCRIPTION

https://registry.npmjs.org is blocked by my company. We use a private repository, and want to enforce it's use in our Node.js projects via a .corepack.env file.

COREPACK_NPM_REGISTRY=https://our.private.repo
$ corepack use pnpm
Internal Error: Error when performing the request to https://registry.npmjs.org/pnpm; for troubleshooting help, see https://github.com/nodejs/corepack#troubleshooting
    at fetch (/Users/gadzy/.local/share/fnm/node-versions/v22.19.0/installation/lib/node_modules/corepack/dist/lib/corepack.cjs:22051:11)
    at process.processTicksAndRejections (node:internal/process/task_queues:105:5)
    at async fetchAsJson (/Users/gadzy/.local/share/fnm/node-versions/v22.19.0/installation/lib/node_modules/corepack/dist/lib/corepack.cjs:22065:20)
    at async fetchAvailableVersions (/Users/gadzy/.local/share/fnm/node-versions/v22.19.0/installation/lib/node_modules/corepack/dist/lib/corepack.cjs:22009:20)
    at async fetchAvailableVersions2 (/Users/gadzy/.local/share/fnm/node-versions/v22.19.0/installation/lib/node_modules/corepack/dist/lib/corepack.cjs:22146:14)
    at async /Users/gadzy/.local/share/fnm/node-versions/v22.19.0/installation/lib/node_modules/corepack/dist/lib/corepack.cjs:23001:25
    at async Promise.all (index 1)
    at async Engine.resolveDescriptor (/Users/gadzy/.local/share/fnm/node-versions/v22.19.0/installation/lib/node_modules/corepack/dist/lib/corepack.cjs:22998:22)
    at async UseCommand.execute (/Users/gadzy/.local/share/fnm/node-versions/v22.19.0/installation/lib/node_modules/corepack/dist/lib/corepack.cjs:23469:22)
    at async UseCommand.validateAndExecute (/Users/gadzy/.local/share/fnm/node-versions/v22.19.0/installation/lib/node_modules/corepack/dist/lib/corepack.cjs:20258:22)
$ COREPACK_NPM_REGISTRY=https://our.private.repo corepack use pnpm
Installing [email protected] in the project...

Gadzy avatar Sep 18 '25 16:09 Gadzy

PROBLEMA

corepack useno carga COREPACK_NPM_REGISTRYdesde.corepack.env

CONFIGURACIÓN

  • macOS v15.6.1
  • NodeJS v22.19.0
  • paquete básico v0.34.0

DESCRIPCIÓN

https://registry.npmjs.orgMi empresa lo bloquea. Usamos un repositorio privado y queremos forzar su uso en nuestros Node.jsproyectos mediante un .corepack.envarchivo.

COREPACK_NPM_REGISTRY=https://our.private.repo

$ corepack use pnpm
Internal Error: Error when performing the request to https://registry.npmjs.org/pnpm; for troubleshooting help, see https://github.com/nodejs/corepack#troubleshooting
    at fetch (/Users/gadzy/.local/share/fnm/node-versions/v22.19.0/installation/lib/node_modules/corepack/dist/lib/corepack.cjs:22051:11)
    at process.processTicksAndRejections (node:internal/process/task_queues:105:5)
    at async fetchAsJson (/Users/gadzy/.local/share/fnm/node-versions/v22.19.0/installation/lib/node_modules/corepack/dist/lib/corepack.cjs:22065:20)
    at async fetchAvailableVersions (/Users/gadzy/.local/share/fnm/node-versions/v22.19.0/installation/lib/node_modules/corepack/dist/lib/corepack.cjs:22009:20)
    at async fetchAvailableVersions2 (/Users/gadzy/.local/share/fnm/node-versions/v22.19.0/installation/lib/node_modules/corepack/dist/lib/corepack.cjs:22146:14)
    at async /Users/gadzy/.local/share/fnm/node-versions/v22.19.0/installation/lib/node_modules/corepack/dist/lib/corepack.cjs:23001:25
    at async Promise.all (index 1)
    at async Engine.resolveDescriptor (/Users/gadzy/.local/share/fnm/node-versions/v22.19.0/installation/lib/node_modules/corepack/dist/lib/corepack.cjs:22998:22)
    at async UseCommand.execute (/Users/gadzy/.local/share/fnm/node-versions/v22.19.0/installation/lib/node_modules/corepack/dist/lib/corepack.cjs:23469:22)
    at async UseCommand.validateAndExecute (/Users/gadzy/.local/share/fnm/node-versions/v22.19.0/installation/lib/node_modules/corepack/dist/lib/corepack.cjs:20258:22)
$ COREPACK_NPM_REGISTRY=https://our.private.repo corepack use pnpm
Installing [email protected] in the project...

0b492c9c97e4b3d5e9a139eeedb931860127b470

Isaac9710009 avatar Sep 21 '25 11:09 Isaac9710009

Can you please run the command with DEBUG=corepack set in your env?

aduh95 avatar Sep 22 '25 11:09 aduh95

Can you please run the command with DEBUG=corepack set in your env?

Sure. You can see from the working one that the env file is loaded after the install.

$ DEBUG=corepack* corepack use pnpm
Internal Error: Error when performing the request to https://registry.npmjs.org/pnpm; for troubleshooting help, see https://github.com/nodejs/corepack#troubleshooting
    at fetch (/Users/gadzy/.local/share/fnm/node-versions/v22.16.0/installation/lib/node_modules/corepack/dist/lib/corepack.cjs:22051:11)
    at process.processTicksAndRejections (node:internal/process/task_queues:105:5)
    at async fetchAsJson (/Users/gadzy/.local/share/fnm/node-versions/v22.16.0/installation/lib/node_modules/corepack/dist/lib/corepack.cjs:22065:20)
    at async fetchAvailableVersions (/Users/gadzy/.local/share/fnm/node-versions/v22.16.0/installation/lib/node_modules/corepack/dist/lib/corepack.cjs:22009:20)
    at async fetchAvailableVersions2 (/Users/gadzy/.local/share/fnm/node-versions/v22.16.0/installation/lib/node_modules/corepack/dist/lib/corepack.cjs:22146:14)
    at async /Users/gadzy/.local/share/fnm/node-versions/v22.16.0/installation/lib/node_modules/corepack/dist/lib/corepack.cjs:23001:25
    at async Promise.all (index 0)
    at async Engine.resolveDescriptor (/Users/gadzy/.local/share/fnm/node-versions/v22.16.0/installation/lib/node_modules/corepack/dist/lib/corepack.cjs:22998:22)
    at async UseCommand.execute (/Users/gadzy/.local/share/fnm/node-versions/v22.16.0/installation/lib/node_modules/corepack/dist/lib/corepack.cjs:23469:22)
    at async UseCommand.validateAndExecute (/Users/gadzy/.local/share/fnm/node-versions/v22.16.0/installation/lib/node_modules/corepack/dist/lib/corepack.cjs:20258:22)
$ DEBUG=corepack* COREPACK_NPM_REGISTRY=https://our.private.repo corepack use pnpm
Installing [email protected] in the project...
  corepack Installing [email protected] from https://our.private.repo/pnpm/-/pnpm-10.17.0.tgz +0ms
  corepack Downloading to /Users/gadzy/.cache/node/corepack/v1/corepack-23647-787e3d98.fbc42 +2ms
  corepack LastKnownGood file would be located at /Users/gadzy/.cache/node/corepack/lastKnownGood.json +350ms
  corepack Download and install of [email protected] is finished +0ms
  corepack Checking /Users/gadzy/code-repo/package.json +0ms
  corepack Checking /Users/gadzy/code-repo/.corepack.env +1ms
  corepack Successfully loaded env file found at /Users/gadzy/code-repo/.corepack.env +0ms
  corepack /Users/gadzy/code-repo/package.json defines [email protected] as local package manager +0ms

Already up to date
Done in 110ms using pnpm v10.17.0 

Gadzy avatar Sep 22 '25 12:09 Gadzy

Yeah it looks like .corepack.env is completely ignored when running corepack use, looks like an oversight. Any chance you would like to submit a patch for this?

aduh95 avatar Sep 22 '25 13:09 aduh95

I'm not familiar with the repo, but I can give it a try.

Gadzy avatar Sep 22 '25 22:09 Gadzy