I need to download packagemanager from private http npm registry.
There's an error when I execute the command
COREPACK_NPM_REGISTRY="http://npm.mycompany.com/" corepack prepare pnpm@8.6.12
Error
Preparing pnpm@8.6.12...
Type Error: Protocol "http:" not supported. Expected "https:"
at new NodeError (node:internal/errors:387:5)
at new ClientRequest (node:_http_client:186:11)
at request (node:https:357:10)
at Object.get (node:https:391:15)
at C:\Users\admin\AppData\Roaming\nvm\v16.20.1\node_modules\corepack\dist\corepack.js:43946:27
at new Promise (<anonymous>)
at fetchUrlStream (C:\Users\admin\AppData\Roaming\nvm\v16.20.1\node_modules\corepack\dist\corepack.js:43945:10)
at async installVersion (C:\Users\admin\AppData\Roaming\nvm\v16.20.1\node_modules\corepack\dist\corepack.js:44121:18)
at async Engine.ensurePackageManager (C:\Users\admin\AppData\Roaming\nvm\v16.20.1\node_modules\corepack\dist\corepack.js:44309:31)
at async PrepareCommand.execute (C:\Users\admin\AppData\Roaming\nvm\v16.20.1\node_modules\corepack\dist\corepack.js:44713:27)
Notice that all packagemanagers(npm, pnpm and yarn) support download package through custom registry with http protocol.
Maybe we can support download packagemanagers from custom REGISTRY with http protocol?
|
const {default: https} = await import(`https`); |
|
|
|
const {ProxyAgent} = await import(`proxy-agent`); |
|
|
|
const proxyAgent = new ProxyAgent(); |
|
|
|
return new Promise<IncomingMessage>((resolve, reject) => { |
|
const request = https.get(url, {...options, agent: proxyAgent}, response => { |
|
const statusCode = response.statusCode; |
|
if (statusCode != null && statusCode >= 200 && statusCode < 300) |
|
return resolve(response); |
|
|
|
return reject(new Error(`Server answered with HTTP ${statusCode} when performing the request to ${url}; for troubleshooting help, see https://github.com/nodejs/corepack#troubleshooting`)); |
|
}); |
|
|
|
request.on(`error`, err => { |
|
reject(new Error(`Error when performing the request to ${url}; for troubleshooting help, see https://github.com/nodejs/corepack#troubleshooting`)); |
|
}); |
|
}); |
If possible, I can work with the issue.
Enviroment
- node: 16.20.1
- corepack: 0.17.0
I need to download packagemanager from private http npm registry.
There's an error when I execute the command
COREPACK_NPM_REGISTRY="http://npm.mycompany.com/" corepack prepare pnpm@8.6.12Error
Notice that all packagemanagers(npm, pnpm and yarn) support download package through custom registry with http protocol.
Maybe we can support download packagemanagers from custom REGISTRY with http protocol?
corepack/sources/httpUtils.ts
Lines 9 to 27 in b8a4a52
If possible, I can work with the issue.
Enviroment