sindresorhus / normalize-url

Normalize a URL
MIT License
840 stars 122 forks source link

URL is not defined error #107

Closed a10kiloham closed 4 years ago

a10kiloham commented 4 years ago

with a fresh plain test.js


const normalizeUrl = require("normalize-url");
main();
function main(){
 let url = 'doctify.co.uk';
 website = normalizeUrl(url);
 console.log(website);
}
        const urlObj = new URL(urlString);
                       ^

ReferenceError: URL is not defined
    at normalizeUrl (/home/xxx/Dropbox/Node/Dealwatch/node_modules/normalize-url/index.js:93:17)
    at main (/home/xxx/Dropbox/Node/Dealwatch/test.js:6:12)
    at Object.<anonymous> (/home/xxx/Dropbox/Node/Dealwatch/test.js:3:1)
    at Module._compile (module.js:653:30)
    at Object.Module._extensions..js (module.js:664:10)
    at Module.load (module.js:566:32)
    at tryModuleLoad (module.js:506:12)
    at Function.Module._load (module.js:498:3)
    at Function.Module.runMain (module.js:694:10)
    at startup (bootstrap_node.js:204:16)
sindresorhus commented 4 years ago

Upgrade your Node.js version.

a10kiloham commented 4 years ago

ah crap, thanks :) had no idea apt wouldn't update node automatically. i was on version 8!