Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Cannot find module './types/standard' from 'index.js' #2754

Closed
budarin opened this issue Jun 16, 2018 · 5 comments
Closed

Cannot find module './types/standard' from 'index.js' #2754

budarin opened this issue Jun 16, 2018 · 5 comments

Comments

@budarin
Copy link

budarin commented Jun 16, 2018

Steps to reproduce

Tell us about your environment:

  • Puppeteer version: 1.5.0
  • Platform / OS version: Windows 7
  • URLs (if applicable): repo
  • Node.js version: 10.4.0

What steps will reproduce the problem?

Please include code that reproduces the issue.

  1. upgrade puppeteer from 1.1.1 to 1.5.0 version
  2. run test: ````npm test App1```

What is the expected result?
to run puppeteer

What happens instead?
error:

    Cannot find module './types/standard' from 'index.js'

      at Resolver.resolveModule (../node_modules/jest-resolve/build/index.js:210:17)
      at Object.<anonymous> (../node_modules/puppeteer/node_modules/mime/index.js:4:27)

if I return to 1.1.1 version - puppeteer runs and pass the test

@Prior99
Copy link

Prior99 commented Jun 19, 2018

I am experiencing the exact same error with version 1.5.0 and it works just fine when downgrading to 1.1.1.

@jonjiang1
Copy link

Also had the same error and downgrading worked. Is there no other fix though?

@aslushnikov
Copy link
Contributor

I see you've managed to upgrade to 1.5.0 here: budarin/react-http2-bootstrap-project@9892390

The error itself doesn't relate to puppeteer: instead it has something to do with jest module resolution.

@AdirAmsalem
Copy link

AdirAmsalem commented Jul 8, 2018

Cause:
The error happens because puppeteer v1.5 started to use [email protected]: 37cc9f5#diff-b9cfc7f2cdf78a7f4b91a753d10865a2R32).

in [email protected] they added a require to a JSON file: https://github.com/broofa/node-mime/blob/master/index.js#L4

Most "copy-paste" Jest configurations doesn't support loading JSONs as-is, so that's probably the cause.

To solve the problem:
Simply add "json" to the moduleFileExtensions entry in the jest property in your package.json file.

// package.json

"jest": {
  "moduleFileExtensions": [
    "json"
  ]
}

- You probably already have other extensions there, so make sure not to remove them but to add "json" in addition.

AngusFu added a commit to clair-design/clair that referenced this issue Sep 14, 2018
Hakier added a commit to Hakier/extract-from-document that referenced this issue Apr 6, 2019
 * added json to `moduleFileExtensions` entry in the `jest` due to puppeteer/puppeteer#2754 (comment)
 * fixed int tests of extract
 * updated .gitignore to not ignore jest.config.js
 * added tslint config
 * added .gitignore
 * updated @types/jest and @types/puppeteer
 * installed winston as peer dependency of @hakier/logger
@alexesca
Copy link

alexesca commented Jul 7, 2020

This error is pretty clear. Jests outputs You might want to include a file extension in your import, or update your 'moduleFileExtensions', which is currently ['ts', 'tsx', 'js', 'jsx', 'html']. I added the file extension(in this case json) to my moduleFileExtension field in the jest.config.js of my lib. If you are using a monorepo, every app/lib creates its own jest.config.js.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

6 participants