gpt4 book ai didi

node.js - 引用错误: URL is not defined when trying to Run lighthouse reports on the command line in linux

转载 作者:太空宇宙 更新时间:2023-11-03 23:53:02 24 4
gpt4 key购买 nike

我已经安装了 chrome、Node 的 LTS 版本和 lighthouse,但当我尝试运行审核时出现以下错误:

/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)

安装完所需的所有内容后,我尝试测试它并收到上述错误。

灯塔https://www.bbc.co.uk

据我了解,您可以在命令行中输入 lighthouse,然后输入您要对其进行审核的网站的 URL。但我不断得到:

ReferenceError: URL is not defined.

我是不是做错了什么?请帮忙。

最佳答案

我也遇到了同样的问题。您的 Node 版本已过时。通过运行 node --version

进行检查

如果它小于 10,那么您就找到了问题。

https://nodejs.org/api/globals.html#globals_url

更新 Node :

sudo npm cache clean -f
sudo npm install -g n
sudo n stable

然后再次检查您的 Node 版本:

node --version

您也可以使用 sudo nlatest 安装最新版本,但我建议使用 stable。

关于node.js - 引用错误: URL is not defined when trying to Run lighthouse reports on the command line in linux,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/58621264/

24 4 0
Copyright 2021 - 2024 cfsdn All Rights Reserved 蜀ICP备2022000587号
广告合作:1813099741@qq.com 6ren.com