Lighthouse CLI error in CI - Unexpected token .
We(on MDN Web Docs) recently started seeing the following error for our Lighthouse tests running via GitHub Actions:
performance.yml workflow file we had the following:
- name: Setup Node.js environment uses: email@example.com with: node-version: "12"
We are always installing the latest version of Lighthouse and, with the release of version 0.9.0, one of the breaking changes was that the project dropped support for Nodejs versions lower than 14. Aha! And in that lies the problem.
The fix was trivial. All that we needed to do was bump the version of Nodejs to 14.
- name: Setup Node.js environment uses: firstname.lastname@example.org with: node-version: "14"
And with that, everything works again. A better fix in this case would probably be to actually stick to a specific release instead of always installing the latest version. However, should you run into this error, now you know how to fix it!