Lighthouse: Cannot find module 'intl'

Created on 28 Jun 2019  路  7Comments  路  Source: GoogleChrome/lighthouse

Provide the steps to reproduce

  1. Run LH on cypress
import lighthouse from 'lighthouse';
describe('My First Test', function() {
  it('Does not do much!', function() {
    expect(true).to.equal(true);
  });
});

repo with example:
https://github.com/bote795/cypress-test-tiny

npm run cypress:run

What is the current behavior?

Doesn't really get past the first line
Error: Cannot find module 'intl' from '/Users/nicolasbotello/Documents/workspace/code/rmc/node_modules/lighthouse/lighthouse-core/lib/i18n'

What is the expected behavior?

file to run successfully don't get any errors.

Environment Information

  • Affected Channels:
  • Lighthouse version: 5.1.0
  • Node.js version:v10.15.0
  • Operating System: Macos

Related issues
Not sure if this is a lighthouse or cypress issue?

All 7 comments

intl is a dev dep for LH, which is why you don't get it installed when adding lighthouse to your package.json deps.

You can add intl and it will fix it (but then the next missing module comes up, bufferutil ...)

As to what LH should change, maybe intl should be part of our dependencies? @brendankenny / @exterkamp might know more, I'm not very familiar with how i18n.js works.

Also, thanks for providing a repro! Very useful.

@connorjclark so if i add intl then bufferutil, it will just continue to ask to install everything right?

Maybe? We don't even use bufferutil - it is included via ws devDeps much like how we include intl (in a try/catch):

image

I'm guessing cypress doesn't like that paradigm very much. If there's one issue to report to cypress, that may be it.

This sounds like a cypress issue. All of these require statements are guarded by try/catch and in normal node execution should pass right on through the optional requires just fine.

That being said, we should probably be moving our intl dependency to dependencies though as @connorjclark points out. Right now most node consumers probably don't know they would need to install this package manually for complete i18n support.

so I added bufferutil, intl, utf-8-validate
Then I got the following error

Uncaught TypeError: require.resolve is not a function

This error originated from your test code, not from Cypress.

When Cypress detects uncaught errors originating from your test code it will automatically fail the current test.

Cypress could not associate this error to any specific test.

We dynamically generated a new test to display this failure.

will follow up with the cypress team.
Thanks for y'alls help!

@bote795 I am working in the same approach (cypress + lighthouse) and facing the same issue. Could you find a workaround?

Was this page helpful?
0 / 5 - 0 ratings

Related issues

nl-igor picture nl-igor  路  3Comments

dkajtoch picture dkajtoch  路  3Comments

bitttttten picture bitttttten  路  3Comments

radum picture radum  路  3Comments

johnfrancisli picture johnfrancisli  路  3Comments