question-mark
Stuck on an issue?

Lightrun Answers was designed to reduce the constant googling that comes with debugging 3rd party libraries. It collects links to all the places you might be looking at while hunting down a tough bug.

And, if you’re still stuck at the end, we’re happy to hop on a call to see how we can help out.

babel-jest module isn't found if not added directly

See original GitHub issue

Hi guys, I noticed today that I cannot run tests anymore if I have setup Babel transpilation for JS files.

I get this error

● Validation Error:

  Module babel-jest in the transform option was not found.
         <rootDir> is: D:\Sources\smile80\libs\renderer

  Configuration Documentation:
  https://jestjs.io/docs/configuration.html

I checked my yarn.lock file and babel-jest is actually present in the file, but there’s no folder into node_modules, that may be the cause. Lately I upgraded to yarn 1.16.0, so I tried downgrading to 1.15.2, but with no results: same error.

If I add it as a direct dependency, it restarts working. I’m pretty confused right now, I checked my history and I’m pretty sure that 2 days ago I launched my tests without problems and without babel-jest as direct dependency.

Issue Analytics

  • State:closed
  • Created 4 years ago
  • Comments:9 (4 by maintainers)

github_iconTop GitHub Comments

16reactions
inlightmediacommented, Oct 27, 2020

I ran into this when using yarn workspaces. One of my packages was using babel-jest for testing but when I added babel-jest to the package.json it would add to the repo’s root yarn.lock file and not to the node_modules folder of the package. In my jest transform I was referencing babel-jest like this:

transform: {
        "^.+\\.(js|jsx|ts|tsx)$": "./node_modules/.bin/babel-jest",
},

To fix, I just removed the relative path:

transform: {
        "^.+\\.(js|jsx|ts|tsx)$": "babel-jest",
},
3reactions
aManNamedJedcommented, Apr 18, 2021

@inlightmedia Not all heroes wear capes, or perhaps you do, in which case I like you even more. Thank you!

Read more comments on GitHub >

github_iconTop Results From Across the Web

Issue with babel-jest dependency when running npm start in a ...
First of all, read the error message in the cmd from the beginning. They'll tell you what module is causing the problem. ·...
Read more >
Getting Started - Jest
You can run Jest directly from the CLI (if it's globally available in your PATH , e.g. by yarn global add jest or...
Read more >
babel/preset-env
@babel/preset-env would not be possible if not for a number of awesome ... @babel/preset-env will add direct references to core-js modules as bare...
Read more >
cannot find module 'jest-config' - You.com | The AI Search ...
If the error Cannot find module issue in vue jest testing occures, set the preset property of jest.config.js file as below. module.exports =...
Read more >
babel-jest | Yarn - Package Manager
If you are already using jest-cli , add babel-jest and it will automatically compile JavaScript code using Babel. yarn add --dev babel-jest @babel/core....
Read more >

github_iconTop Related Medium Post

No results found

github_iconTop Related StackOverflow Question

No results found

github_iconTroubleshoot Live Code

Lightrun enables developers to add logs, metrics and snapshots to live code - no restarts or redeploys required.
Start Free

github_iconTop Related Reddit Thread

No results found

github_iconTop Related Hackernoon Post

No results found

github_iconTop Related Tweet

No results found

github_iconTop Related Dev.to Post

No results found

github_iconTop Related Hashnode Post

No results found