Lighthouse-ci: How to fix "Must provide token for LHCI target"

Created on 9 Dec 2019  ·  3Comments  ·  Source: GoogleChrome/lighthouse-ci

While trying to run LHCI with assertions. I see the below error.
lgummad$ lhci autorun --collect.url=https://node.js.org/
✅ .lighthouseci/ directory writable
✅ Configuration file found
✅ Chrome installation found
⚠️ GitHub token not set
Healthcheck passed!

Running Lighthouse 2 time(s) on https://node.js.org/
Run #1...done.
Run #2...done.
Done running Lighthouse!

Checking assertions against 1 URL(s), 2 total run(s)

All results processed!

Error: Must provide token for LHCI target
at runLHCITarget (/Users/lgummad/.nvm/versions/node/v10.11.0/lib/node_modules/@lhci/cli/src/upload/upload.js:212:29)
at Object.runCommand (/Users/lgummad/.nvm/versions/node/v10.11.0/lib/node_modules/@lhci/cli/src/upload/upload.js:323:14)
at run (/Users/lgummad/.nvm/versions/node/v10.11.0/lib/node_modules/@lhci/cli/src/cli.js:90:23)
at Object. (/Users/lgummad/.nvm/versions/node/v10.11.0/lib/node_modules/@lhci/cli/src/cli.js:118:1)
at Module._compile (internal/modules/cjs/loader.js:689:30)
at Object.Module._extensions..js (internal/modules/cjs/loader.js:700:10)
at Module.load (internal/modules/cjs/loader.js:599:32)
at tryModuleLoad (internal/modules/cjs/loader.js:538:12)
at Function.Module._load (internal/modules/cjs/loader.js:530:3)
at Function.Module.runMain (internal/modules/cjs/loader.js:742:12)
WARNING: upload command failed.
Done running autorun.

My node version: 10.11
using latest chrome version: 78
Lighthouse and lighthouse-ci are using latest
Command I use: lhci autorun --collect.url=https://node.js.org/
My lighthouserec.json looks like

{
"ci": {
"collect": {
"numberOfRuns": 2
},
"assert": {
"assertions": {

"first-contentful-paint": [
"error",
{"maxNumericValue": 5000, "aggregationMethod": "optimistic"}
],
"interactive": ["error", {"maxNumericValue": 9000, "aggregationMethod": "optimistic"}]
}
},
"upload": {
"target": "lhci",
"serverBaseUrl": "https://lhci.example.com"
}
}
}
question

Most helpful comment

Hi @lgummadi7, when you use target with lhci you need to provide a project token as specify in the cli docs.

If you don't have a Lighthouse CI server running you can change the target to temporary-public-storage and remove the serverBaseUrl.

All 3 comments

Hi @lgummadi7, when you use target with lhci you need to provide a project token as specify in the cli docs.

If you don't have a Lighthouse CI server running you can change the target to temporary-public-storage and remove the serverBaseUrl.

@jzabala is exactly right 👍

Just for completeness sake of other readers you also have two other options:

  1. Setup your own server and get a token using the docker or heroku guides.
  2. Don't upload the results anywhere. You could just delete the upload object from your lighthouserc.json if you'd like (though we do think temporary-public-storage + the GitHub app is pretty cool 😉)

Closing as resolved. Please file a new issue if you there any further problems.

Was this page helpful?
0 / 5 - 0 ratings