Skip to content

HTTPS clone URL

Subversion checkout URL

You can clone with HTTPS or Subversion.

Download ZIP

Loading…

npm ERR! TypeError: Cannot call method 'toLowerCase' of undefined #727

Closed
giver opened this Issue · 12 comments

2 participants

Tanin Srivaraphong isaacs
Tanin Srivaraphong

$npm install express
npm info it worked if it ends with ok
npm info using npm@0.3.15
npm info using node@v0.4.3
npm ERR! TypeError: Cannot call method 'toLowerCase' of undefined
npm ERR! at request (/usr/local/lib/node/.npm/npm/0.3.15/package/lib/utils/registry/request.js:98:40)
npm ERR! at GET (/usr/local/lib/node/.npm/npm/0.3.15/package/lib/utils/registry/request.js:227:3)
npm ERR! at get_ (/usr/local/lib/node/.npm/npm/0.3.15/package/lib/utils/registry/get.js:43:3)
npm ERR! at /usr/local/lib/node/.npm/npm/0.3.15/package/lib/utils/registry/get.js:30:10
npm ERR! at cb (/usr/local/lib/node/.npm/npm/0.3.15/package/lib/utils/graceful-fs.js:31:9)
npm ERR! Report this entire log at http://github.com/isaacs/npm/issues
npm ERR! or email it to npm-@googlegroups.com
npm ERR! Just tweeting a tiny part of the error will not be helpful.
npm ERR! System Darwin 10.6.0
npm ERR! argv { remain: [ 'express' ],
npm ERR! argv cooked: [ 'install', 'express' ],
npm ERR! argv original: [ 'install', 'express' ] }
npm not ok

isaacs
Owner

Well, that's odd. The remote url should always have a protocol on it.

What does npm get registry -s and npm get proxy -s show?

isaacs isaacs closed this
Tanin Srivaraphong

$ npm get registry -s

"https://registry.npmjs.org/"

$ npm get proxy -s

null

$

isaacs
Owner
Tanin Srivaraphong

Hi isaacs,

I don't know if error message "TypeError: Cannot call method 'toLowerCase' of undefined" could be related with DNS?

Here is my error message

$ npm install express -dd
npm info it worked if it ends with ok  
npm verb cli [ 'install',  
npm verb cli   'express',  
npm verb cli   '--loglevel',  
npm verb cli   'verbose' ]  
npm info using npm@0.3.15  
npm info using node@v0.4.3  
npm verb /usr/local/bin/node node symlink  
npm verb config file /Users/giver/.npmrc  
npm verb config file /usr/local/etc/npmrc  
npm verb install [ 'express' ]  
npm verb install [ 'express' ]  
npm verb install pkglist [ 'express' ]  
npm verb must install [ 'express' ]  
npm verb install_ express  
npm verb must install? [ [ 'express' ], true ]  
npm verb GET express  
npm ERR! TypeError: Cannot call method 'toLowerCase' of undefined  
npm ERR!     at request (/usr/local/lib/node/.npm/npm/0.3.15/package/lib/utils/registry/request.js:98:40)  
npm ERR!     at GET (/usr/local/lib/node/.npm/npm/0.3.15/package/lib/utils/registry/request.js:227:3)  
npm ERR!     at get_ (/usr/local/lib/node/.npm/npm/0.3.15/package/lib/utils/registry/get.js:43:3)  
npm ERR!     at /usr/local/lib/node/.npm/npm/0.3.15/package/lib/utils/registry/get.js:30:10  
npm ERR!     at cb (/usr/local/lib/node/.npm/npm/0.3.15/package/lib/utils/graceful-fs.js:31:9)  
npm ERR! Report this *entire* log at   
npm ERR! or email it to   
npm ERR! Just tweeting a tiny part of the error will not be helpful.  
npm ERR! System Darwin 10.6.0  
npm ERR! argv { remain: [ 'express' ],  
npm ERR! argv   cooked:  
npm ERR! argv    [ 'install',  
npm ERR! argv      'express',  
npm ERR! argv      '--loglevel',  
npm ERR! argv      'verbose' ],  
npm ERR! argv   original:  
npm ERR! argv    [ 'install',  
npm ERR! argv      'express',  
npm ERR! argv      '-dd' ] }  
npm verb exit [ 1, true ]  
npm not ok
$ 
isaacs
Owner

Ok, weird.

I just published 0.3.16, which includes a bit of workaround for this issue, as well as a warning when it's found. Can you upgrade and see how it goes? If npm i npm doesn't work (for this issue!) then try curl http://npmjs.org/install.sh | sh

Tanin Srivaraphong

Another problem had occurred. I can access "http://search.npmjs.org/#/express" without problem.

$ npm install express -dd
npm info it worked if it ends with ok
npm verb cli [ 'install',
npm verb cli   'express',
npm verb cli   '--loglevel',
npm verb cli   'verbose' ]
npm info using npm@0.3.16
npm info using node@v0.4.3
npm verb /usr/local/bin/node node symlink
npm verb config file /Users/giver/.npmrc
npm verb config file /usr/local/etc/npmrc
npm verb install [ 'express' ]
npm verb install [ 'express' ]
npm verb install pkglist [ 'express' ]
npm verb must install [ 'express' ]
npm verb install_ express
npm verb must install? [ [ 'express' ], true ]
npm verb GET express
npm WARN No protocol? { pathname: 'express',
npm WARN No protocol?   href: 'express' }
npm ERR! Error: ECONNREFUSED, Connection refused
npm ERR!     at Socket._onConnect (net.js:597:18)
npm ERR!     at IOWatcher.onWritable [as callback] (net.js:186:12)
npm ERR! If you are using Cygwin, please set up your /etc/resolv.conf
npm ERR! See step 4 in this wiki page:
npm ERR!     http://github.com/ry/node/wiki/Building-node.js-on-Cygwin-%28Windows%29
npm ERR! If you are not using Cygwin, please report this
npm ERR! at 
npm ERR! or email it to 
npm ERR! System Darwin 10.6.0
npm ERR! argv { remain: [ 'express' ],
npm ERR! argv   cooked: 
npm ERR! argv    [ 'install',
npm ERR! argv      'express',
npm ERR! argv      '--loglevel',
npm ERR! argv      'verbose' ],
npm ERR! argv   original: 
npm ERR! argv    [ 'install',
npm ERR! argv      'express',
npm ERR! argv      '-dd' ] }
npm verb exit [ 61, true ]
npm not ok
$
isaacs
Owner

Ok, let's try this:

npm explore npm
cd lib/utils/registry/
curl https://github.com/isaacs/npm/raw/0ab84bfaadbeae4776e2226a348750d89bc8d77d/lib/utils/registry/request.js > request.js
exit

And then do your npm install express -dd again. I just spammed it with verbose logs.

Tanin Srivaraphong

After I try your step. The problem wasn't gone.

$ npm install express -dd
npm info it worked if it ends with ok
npm verb cli [ 'install',
npm verb cli   'express',
npm verb cli   '--loglevel',
npm verb cli   'verbose' ]
npm info using npm@0.3.16
npm info using node@v0.4.3
npm verb /usr/local/bin/node node symlink
npm verb config file /Users/giver/.npmrc
npm verb config file /usr/local/etc/npmrc
npm verb install [ 'express' ]
npm verb install [ 'express' ]
npm verb install pkglist [ 'express' ]
npm verb must install [ 'express' ]
npm verb install_ express
npm verb must install? [ [ 'express' ], true ]
npm verb GET express
npm verb etag "5M1T50C3IMPFBTD11753L76YF"
npm WARN No protocol? { pathname: 'express',
npm WARN No protocol?   href: 'express' }
npm ERR! Error: ECONNREFUSED, Connection refused
npm ERR!     at Socket._onConnect (net.js:597:18)
npm ERR!     at IOWatcher.onWritable [as callback] (net.js:186:12)
npm ERR! If you are using Cygwin, please set up your /etc/resolv.conf
npm ERR! See step 4 in this wiki page:
npm ERR!     http://github.com/ry/node/wiki/Building-node.js-on-Cygwin-%28Windows%29
npm ERR! If you are not using Cygwin, please report this
npm ERR! at 
npm ERR! or email it to 
npm ERR! System Darwin 10.6.0
npm ERR! argv { remain: [ 'express' ],
npm ERR! argv   cooked: 
npm ERR! argv    [ 'install',
npm ERR! argv      'express',
npm ERR! argv      '--loglevel',
npm ERR! argv      'verbose' ],
npm ERR! argv   original: 
npm ERR! argv    [ 'install',
npm ERR! argv      'express',
npm ERR! argv      '-dd' ] }
npm verb exit [ 61, true ]
npm not ok
$

After the problem still exist. I try to use common way with the following command and successful install. I'm not sure why sudo npm install express not similar with sudo su - and then npm install express

My successful step

1) Switch my login to root with sudo su - ( NOT sudo npm install express)

2) npm install express

3) Successful installed

# npm install express    
npm info it worked if it ends with ok
npm info using npm@0.3.16
npm info using node@v0.4.3
npm info preinstall express@2.0.0
npm info install express@2.0.0
npm info postinstall express@2.0.0
npm info predeactivate express@2.0.0
npm info deactivate express@2.0.0
npm info postdeactivate express@2.0.0
npm info preactivate express@2.0.0
npm info activate express@2.0.0
npm info postactivate express@2.0.0
npm info build Success: express@2.0.0
npm ok
#
isaacs
Owner

You didn't get the changed file. https://github.com/isaacs/npm/raw/0ab84bfaadbeae4776e2226a348750d89bc8d77d/lib/utils/registry/request.js has some additional logging which I don't see in the output above.

Tanin Srivaraphong

Sorry about that because I face with some file permission issue. Here is your expect log, right?

$ npm install express -dd
npm info it worked if it ends with ok
npm verb cli [ 'install',
npm verb cli   'express',
npm verb cli   '--loglevel',
npm verb cli   'verbose' ]
npm info using npm@0.3.16
npm info using node@v0.4.3
npm verb /usr/local/bin/node node symlink
npm verb config file /Users/giver/.npmrc
npm verb config file /usr/local/etc/npmrc
npm verb install [ 'express' ]
npm verb install [ 'express' ]
npm verb install pkglist [ 'express' ]
npm verb must install [ 'express' ]
npm verb install_ express
npm verb must install? [ [ 'express' ], true ]
npm verb GET express
npm verb raw, before any munging express
npm verb url resolving [ '"http://registry.npmjs.org/"/',
npm verb url resolving   './express' ]
npm verb url resolved express
npm verb url parsed express { pathname: 'express',
npm verb url parsed express   href: 'express' }
npm verb etag "5M1T50C3IMPFBTD11753L76YF"
npm WARN No protocol? { pathname: 'express',
npm WARN No protocol?   href: 'express' }
npm ERR! Error: ECONNREFUSED, Connection refused
npm ERR!     at Socket._onConnect (net.js:597:18)
npm ERR!     at IOWatcher.onWritable [as callback] (net.js:186:12)
npm ERR! If you are using Cygwin, please set up your /etc/resolv.conf
npm ERR! See step 4 in this wiki page:
npm ERR!     http://github.com/ry/node/wiki/Building-node.js-on-Cygwin-%28Windows%29
npm ERR! If you are not using Cygwin, please report this
npm ERR! at 
npm ERR! or email it to 
npm ERR! System Darwin 10.6.0
npm ERR! argv { remain: [ 'express' ],
npm ERR! argv   cooked: 
npm ERR! argv    [ 'install',
npm ERR! argv      'express',
npm ERR! argv      '--loglevel',
npm ERR! argv      'verbose' ],
npm ERR! argv   original: 
npm ERR! argv    [ 'install',
npm ERR! argv      'express',
npm ERR! argv      '-dd' ] }
npm verb exit [ 61, true ]
npm not ok
$
isaacs
Owner

Aha, the mystery is resolved! There are quotes around the "registry" config.

Open up ~/.npmrc and delete the line that says registry = "http://registry.npmjs.org". It should not have quotes around it. (You could also do: npm config delete registry to reset it back to the default.)

Thanks for your patience. :)

Tanin Srivaraphong

OK thanks. It works fine. :)

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Something went wrong with that request. Please try again.