Closed Qwarctick closed 1 month ago
Consider setting DEBUG=corepack
in your env to better understand what's happening.
root@ddd6d989a9e8:/src# export DEBUG=corepack
root@ddd6d989a9e8:/src# yarn
corepack LastKnownGood file would be located at /root/.cache/node/corepack/lastKnownGood.json +0ms
corepack No LastKnownGood version found in Corepack home. +4ms
/usr/local/lib/node_modules/corepack/dist/lib/corepack.cjs:21521
throw new UsageError(`Network access disabled by the environment; can't reach npm repository ${npmRegistryUrl}`);
^
UsageError: Network access disabled by the environment; can't reach npm repository https://registry.npmjs.org
at fetchAsJson2 (/usr/local/lib/node_modules/corepack/dist/lib/corepack.cjs:21521:11)
at fetchLatestStableVersion (/usr/local/lib/node_modules/corepack/dist/lib/corepack.cjs:21550:26)
at fetchLatestStableVersion2 (/usr/local/lib/node_modules/corepack/dist/lib/corepack.cjs:21672:20)
at Engine.getDefaultVersion (/usr/local/lib/node_modules/corepack/dist/lib/corepack.cjs:22292:29)
at async Engine.executePackageManagerRequest (/usr/local/lib/node_modules/corepack/dist/lib/corepack.cjs:22390:47)
at async Object.runMain (/usr/local/lib/node_modules/corepack/dist/lib/corepack.cjs:23096:5) {
clipanion: { type: 'usage' }
}
Node.js v22.8.0
No LastKnownGood version found
That seems to be the issue. If you run corepack install -g yarn@4.x
might solve that (I'm just guessing, I'm not using Docker).
where corepack try to fetch data from yarnpkg or npmjs.org even if I set the variable COREPACK_ENABLE_NETWORK=0
To clarify, I don't think that's what happens. When network is disabled by env, Corepack won't even try to fetch anything – and instead throw the error you're seeing. If you actually see some connection attempts from Corepack, that would definitely be a bug, please report it.
OK thanks.
The problem seems to be that corepack does not default to the version of yarn installed by the corepack yarn@4.x install
command. It tries to install yarn 1.1 and fails. It seems to need the packageManager
field in the package.json. But this field doesn't seem to support syntheses like 4.X
.
Ok we fallback in the problem with the semver in packageManager :
Hello,
I'm trying to use corepack in full offline mode. I got an error when running yarn where corepack try to fetch data from yarnpkg or npmjs.org even if I set the variable COREPACK_ENABLE_NETWORK=0.
I created this test case with a container without internet access after installation of corepack/yarn.
package.json
Dockerfile