nodejs / corepack

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

corepack install verbose error #475

Closed eichiflSICKAG closed 2 months ago

eichiflSICKAG commented 2 months ago

corepack version 0.25.2 node version 20.12.2

I try to install yarn via corepack. This fails with the following error:

Adding yarn@4.1.0 to the cache...
Internal Error: Error when performing the request to https://repo.yarnpkg.com/4.1.0/packages/yarnpkg-cli/bin/yarn.js; for troubleshooting help, see https://github.com/nodejs/corepack#troubleshooting
    at fetch (/home/user/.nvm/versions/node/v20.12.2/lib/node_modules/corepack/dist/lib/corepack.cjs:22882:11)
    at async fetchUrlStream (/home/user/.nvm/versions/node/v20.12.2/lib/node_modules/corepack/dist/lib/corepack.cjs:22914:20)
    at async installVersion (/home/user/.nvm/versions/node/v20.12.2/lib/node_modules/corepack/dist/lib/corepack.cjs:23084:18)
    at async Engine.ensurePackageManager (/home/user/.nvm/versions/node/v20.12.2/lib/node_modules/corepack/dist/lib/corepack.cjs:23380:32)
    at async InstallLocalCommand.execute (/home/user/.nvm/versions/node/v20.12.2/lib/node_modules/corepack/dist/lib/corepack.cjs:23903:5)
    at async InstallLocalCommand.validateAndExecute (/home/user/.nvm/versions/node/v20.12.2/lib/node_modules/corepack/dist/lib/corepack.cjs:21173:22)
    at async _Cli.run (/home/user/.nvm/versions/node/v20.12.2/lib/node_modules/corepack/dist/lib/corepack.cjs:22148:18)
    at async Object.runMain (/home/user/.nvm/versions/node/v20.12.2/lib/node_modules/corepack/dist/lib/corepack.cjs:24266:12)

troubleshooting is all done.

I have no idea how to debug this further, as no verbose flag is available and corepack is super silent about the reasons if it's failing.

eichiflSICKAG commented 2 months ago

I further investigated and saw that the error cause is not thrown. Why?

when logging this, the root cause is:

TypeError: fetch failed
    at node:internal/deps/undici/undici:12618:11
    at async fetch (/home/user/.nvm/versions/node/v20.12.2/lib/node_modules/corepack/dist/lib/corepack.cjs:22877:16)
    at async fetchUrlStream (/home/user/.nvm/versions/node/v20.12.2/lib/node_modules/corepack/dist/lib/corepack.cjs:22917:20)
    at async installVersion (/home/user/.nvm/versions/node/v20.12.2/lib/node_modules/corepack/dist/lib/corepack.cjs:23087:18)
    at async Engine.ensurePackageManager (/home/user/.nvm/versions/node/v20.12.2/lib/node_modules/corepack/dist/lib/corepack.cjs:23383:32)
    at async InstallGlobalCommand.installFromDescriptor (/home/user/.nvm/versions/node/v20.12.2/lib/node_modules/corepack/dist/lib/corepack.cjs:23842:5)
    at async InstallGlobalCommand.execute (/home/user/.nvm/versions/node/v20.12.2/lib/node_modules/corepack/dist/lib/corepack.cjs:23824:9)
    at async InstallGlobalCommand.validateAndExecute (/home/user/.nvm/versions/node/v20.12.2/lib/node_modules/corepack/dist/lib/corepack.cjs:21173:22)
    at async _Cli.run (/home/user/.nvm/versions/node/v20.12.2/lib/node_modules/corepack/dist/lib/corepack.cjs:22148:18)
    at async Object.runMain (/home/user/.nvm/versions/node/v20.12.2/lib/node_modules/corepack/dist/lib/corepack.cjs:24269:12) {
  cause: TypeError: this[kClient].connect is not a function
      at Client.connect (/home/user/.nvm/versions/node/v20.12.2/lib/node_modules/corepack/dist/lib/corepack.cjs:13362:66)
      at socket (/home/user/.nvm/versions/node/v20.12.2/lib/node_modules/corepack/dist/lib/corepack.cjs:12289:29)
      at new Promise (<anonymous>)
      at connect (/home/user/.nvm/versions/node/v20.12.2/lib/node_modules/corepack/dist/lib/corepack.cjs:12288:30)
      at _resume (/home/user/.nvm/versions/node/v20.12.2/lib/node_modules/corepack/dist/lib/corepack.cjs:12483:11)
      at resume (/home/user/.nvm/versions/node/v20.12.2/lib/node_modules/corepack/dist/lib/corepack.cjs:12409:7)
      at [dispatch] (/home/user/.nvm/versions/node/v20.12.2/lib/node_modules/corepack/dist/lib/corepack.cjs:11675:11)
      at Intercept (/home/user/.nvm/versions/node/v20.12.2/lib/node_modules/corepack/dist/lib/corepack.cjs:11362:20)
      at [Intercepted Dispatch] (/home/user/.nvm/versions/node/v20.12.2/lib/node_modules/corepack/dist/lib/corepack.cjs:4745:16)
      at Client.dispatch (/home/user/.nvm/versions/node/v20.12.2/lib/node_modules/corepack/dist/lib/corepack.cjs:4761:44)
}
aduh95 commented 2 months ago

Can you try installing the latest version of Corepack? I've encountered this error before, and send a fix – although it was related to a proxy being present, so maybe yours is different, but anyway, trying with the latest version would help with debugging

eichiflSICKAG commented 2 months ago

@aduh95 yes this works perfectly with corepack 28. Also works with 22 but not 25 shipped with node 20.12.2

aduh95 commented 2 months ago

Good to hear! There's a 20.13.0 version of Node.js in preparation that includes Corepack 0.28, this should be fixed soon. (Node.js 20.13.0 is scheduled for release on May 7th, although dates are subject to change). Closing for now, thanks for the report.