npm Install Fails when using http:// registry

registry
priority:medium
triaged

(Zach Berger) #1

What I Wanted to Do

npm install request@2.74.0 --registry=http://registry.npmjs.org/

While behind a HTTP proxy. Expected is request is installed.

What Happened Instead

> npm install request@2.74.0 --verbose --registry=http://registry.npmjs.org/
npm info it worked if it ends with ok
npm verb cli [ '/Users/zberger/.nvm/versions/node/v8.11.3/bin/node',
npm verb cli   '/Users/zberger/.nvm/versions/node/v8.11.3/bin/npm',
npm verb cli   'install',
npm verb cli   'request@2.74.0',
npm verb cli   '--verbose',
npm verb cli   '--registry=http://registry.npmjs.org/' ]
npm info using npm@6.4.0
npm info using node@v8.11.3
npm verb config Skipping project config: /Users/zberger/.npmrc. (matches userconfig)
npm verb npm-session 09ffac614b219f68
npm http fetch GET 418 http://registry.npmjs.org/request 177ms
npm timing stage:rollbackFailedOptional Completed in 0ms
npm timing stage:runTopLevelLifecycles Completed in 372ms
npm verb stack Error: 418 I'm a teapot: request@2.74.0
npm verb stack     at fetch.then.res (/Users/zberger/.nvm/versions/node/v8.11.3/lib/node_modules/npm/node_modules/pacote/lib/fetchers/registry/fetch.js:42:19)
npm verb stack     at tryCatcher (/Users/zberger/.nvm/versions/node/v8.11.3/lib/node_modules/npm/node_modules/bluebird/js/release/util.js:16:23)
npm verb stack     at Promise._settlePromiseFromHandler (/Users/zberger/.nvm/versions/node/v8.11.3/lib/node_modules/npm/node_modules/bluebird/js/release/promise.js:512:31)
npm verb stack     at Promise._settlePromise (/Users/zberger/.nvm/versions/node/v8.11.3/lib/node_modules/npm/node_modules/bluebird/js/release/promise.js:569:18)
npm verb stack     at Promise._settlePromise0 (/Users/zberger/.nvm/versions/node/v8.11.3/lib/node_modules/npm/node_modules/bluebird/js/release/promise.js:614:10)
npm verb stack     at Promise._settlePromises (/Users/zberger/.nvm/versions/node/v8.11.3/lib/node_modules/npm/node_modules/bluebird/js/release/promise.js:693:18)
npm verb stack     at Async._drainQueue (/Users/zberger/.nvm/versions/node/v8.11.3/lib/node_modules/npm/node_modules/bluebird/js/release/async.js:133:16)
npm verb stack     at Async._drainQueues (/Users/zberger/.nvm/versions/node/v8.11.3/lib/node_modules/npm/node_modules/bluebird/js/release/async.js:143:10)
npm verb stack     at Immediate.Async.drainQueues (/Users/zberger/.nvm/versions/node/v8.11.3/lib/node_modules/npm/node_modules/bluebird/js/release/async.js:17:14)
npm verb stack     at runCallback (timers.js:810:20)
npm verb stack     at tryOnImmediate (timers.js:768:5)
npm verb stack     at processImmediate [as _immediateCallback] (timers.js:745:5)
npm verb cwd /Users/zberger
npm verb Darwin 18.0.0
npm verb argv "/Users/zberger/.nvm/versions/node/v8.11.3/bin/node" "/Users/zberger/.nvm/versions/node/v8.11.3/bin/npm" "install" "request@2.74.0" "--verbose" "--registry=http://registry.npmjs.org/"
npm verb node v8.11.3
npm verb npm  v6.4.0
**npm ERR! code E418**
**npm ERR! 418 I'm a teapot: request@2.74.0**
npm verb exit [ 1, true ]

Reproduction Steps

I’m sitting behind a corporate HTTP proxy and whenever I do npm install from the http:// registry it fails with

**npm ERR! code E418**
**npm ERR! 418 I'm a teapot: request@2.74.0**

Details

The issue does not occur when installing from the secure registry. At this point there is a case where we can’t prevent installing from the insecure http registry.

Platform Info

$ npm --versions
6.4.0
$ node -p process.platform
darwin

(Brian Olore) #2

This sounds familiar. It sounds like the HTTP proxy is mangling something in the request that the HTTPS proxy is not :man_shrugging:

I’m curious if you have both HTTP_PROXY and HTTPS_PROXY environment variables set, and if they are set to the same value.