Reputation: 39
I have chrome, LTS version of Node, and lighthouse already installed but get the following error when I try to run an audit:
/usr/local/lib/node_modules/lighthouse/lighthouse-core/lib/url-shim.js:36
class URLShim extends URL {
^
ReferenceError: URL is not defined
at Object.<anonymous> (/usr/local/lib/node_modules/lighthouse/lighthouse-core/lib/url-shim.js:36:23)
at Module._compile (module.js:652:30)
at Object.Module._extensions..js (module.js:663:10)
at Module.load (module.js:565:32)
at tryModuleLoad (module.js:505:12)
at Function.Module._load (module.js:497:3)
at Module.require (module.js:596:17)
at require (internal/module.js:11:18)
at Object.<anonymous> (/usr/local/lib/node_modules/lighthouse/lighthouse-core/lib/network-request.js:14:13)
at Module._compile (module.js:652:30)
After installing all that is required, I try to test it and get the above error.
lighthouse https://www.bbc.co.uk
As I understand it you type lighthouse on the command line followed by the url of the site you're trying to run an audit against. But I keep getting :
ReferenceError: URL is not defined.
Am I doing something wrong. PLEASE HELP.
Upvotes: 2
Views: 7178
Reputation: 71
I had the same issue. Your node version is outdated.
Check it by running node --version
If it's less than 10, then you've found your problem.
https://nodejs.org/api/globals.html#globals_url
To update node:
sudo npm cache clean -f
sudo npm install -g n
sudo n stable
Then check you node version again:
node --version
Optionally, you can also install latest with sudo n latest , but I would recommend going with stable.
Upvotes: 5