TypeError: str.charCodeAt is not a function

haxpanel picture haxpanel · Apr 27, 2016 · Viewed 15.7k times · Source

I updated to node version 6 today and that might've broke something. I tried to get back to node 5.10 but the issue didn't go away. Can this be related to the new V8 engine that is shipped by node v6?

Has anyone experienced this? Any idea?

The last line I could place a breakpoint on (in the node_modules/superagent/lib/node/index.js):

`if ('string' != typeof url) url = format(url);`
  • the value of the variable url is a string, looks like a valid url
  • format() is in the 'url' module as urlFormat()

Error:

TypeError: str.charCodeAt is not a function
    at encodeAuth (url.js:929:17)
    at Request.Url.format (url.js:543:12)
    at urlFormat (url.js:535:63)
    at new Request (/develop/sl/node_modules/superagent/lib/node/index.js:129:11)
    at request (/develop/sl/node_modules/superagent/lib/request.js:26:12)
    at Request.use (/develop/sl/node_modules/superagent/lib/request-base.js:65:3)
    ...

Update: It is probably not related to V8 engine as it is still the v4 instead of the new v5.

$ node -pe 'this.process.versions'
{ http_parser: '2.6.2',
  node: '5.10.1',
  v8: '4.6.85.31',
  uv: '1.8.0',
  zlib: '1.2.8',
  ares: '1.10.1-DEV',
  icu: '56.1',
  modules: '47',
  openssl: '1.0.2g' }

Answer