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

jest cannot resolve source-map-generator module when using configuration file #6514

Closed
marcus-sa opened this issue Jun 21, 2018 · 5 comments
Closed

Comments

@marcus-sa
Copy link

🐛 Bug Report

Due to #6509 I decided to go with two different configuration files, one for my main and one for my renderer process in Electron.
Sadly this is causing issues aswell.

To Reproduce

Create a jest configuration file and run it using jest --config=/path/to/config.

Error log

yarn run v1.7.0
$ jest --config=jest.renderer.config.js
 FAIL  src/renderer/components/ProvideHooks.test.tsx
  ● Test suite failed to run

    Cannot find module './lib/source-map-generator' from 'source-map.js'

      at Resolver.resolveModule (node_modules/jest-resolve/build/index.js:210:17)
      at Object.<anonymous> (node_modules/source-map-support/node_modules/source-map/source-map.js:6:30)

Run npx envinfo --preset jest

System:
    OS: Windows 10
    CPU: x64 Intel(R) Core(TM) i7-7700HQ CPU @ 2.80GHz
  Binaries:
    Yarn: 1.7.0 - ~\AppData\Roaming\npm\yarn.CMD
    npm: 6.1.0 - C:\Program Files\nodejs\npm.CMD
@fnune
Copy link

fnune commented Jun 27, 2018

I just solved this issue on my setup. I suppose you're running a TypeScript-only app, here's what I had before:

In package.json#jest:

    "moduleDirectories": [
      "node_modules",
      "app"
    ],
    "moduleFileExtensions": [
      "ts",
      "tsx"
    ]

I assumed I don't need to add js or jsx to moduleFileExtensions, but adding it solves the issue:

In package.json#jest:

    "moduleDirectories": [
      "node_modules",
      "app"
    ],
    "moduleFileExtensions": [
      "ts",
      "tsx",
      "js",
      "jsx"
    ]

I hope that helps!

@sbstnmsch-zz
Copy link

Confirmed. Weird but this fixes the issue. Thank you!

@fnune
Copy link

fnune commented Jun 28, 2018

@sbstnmsch I don't find it all that weird: my previous declaration for moduleFileExtensions didn't include js, so Jest tried to resolve source-map-generator.js and didn't find it because I implicitly told it to ignore js files.

@sbstnmsch-zz
Copy link

OK understood. I have a typescript-only setup here and forgot about that there still can be js files in the modules. Thanks for clarifying.

tamino-martinius added a commit to tamino-martinius/node-github-graphql-api that referenced this issue Jun 30, 2018
whatwewant added a commit to zcorky/moment that referenced this issue Jan 8, 2019
@github-actions
Copy link

This issue has been automatically locked since there has not been any recent activity after it was closed. Please open a new issue for related bugs.
Please note this issue tracker is not a help forum. We recommend using StackOverflow or our discord channel for questions.

@github-actions github-actions bot locked as resolved and limited conversation to collaborators May 12, 2021
Sign up for free to subscribe to this conversation on GitHub. Already have an account? Sign in.
Labels
None yet
Projects
None yet
Development

No branches or pull requests

3 participants