TypeError: URLParser is not a constructor in Node 6.12.2
Closed this issue · 1 comments
gnicolae14 commented
The normalization function (version 3.1.0) does not work with node 6.12.2
The problem seems to be at the line:
const URLParser = typeof URL === 'undefined' ? require('url').URL : URL;
My guess is that it needs to be:
const URLParser = typeof URL === 'undefined' ? require('url').parse : URL;
Here's a sample how to reproduce the issues:
$ nvm install 6.12.2
$ nvm exec 6.12.2 node
Running node v6.12.2 (npm v3.10.10)
> norm = require('normalize-url')
[Function]
> norm('http://example.com/some/path')
TypeError: URLParser is not a constructor
at module.exports (/Users/jdoe/workspace/node_modules/normalize-url/index.js:32:17)
at repl:1:1
at sigintHandlersWrap (vm.js:22:35)
at sigintHandlersWrap (vm.js:73:12)
at ContextifyScript.Script.runInThisContext (vm.js:21:12)
at REPLServer.defaultEval (repl.js:340:29)
at bound (domain.js:280:14)
at REPLServer.runBound [as eval] (domain.js:293:12)
at REPLServer.<anonymous> (repl.js:539:10)
at emitOne (events.js:101:20)
> require('./node_modules/normalize-url/package').version
'3.1.0'
sindresorhus commented
You need the latest Node.js 6 version (Node.js 6.14).