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 'babel-core' #4891

Closed
ingro opened this issue Nov 14, 2017 · 13 comments
Closed

Cannot find module 'babel-core' #4891

ingro opened this issue Nov 14, 2017 · 13 comments

Comments

@ingro
Copy link

ingro commented Nov 14, 2017

Hello, I've updated jest from 20.0.4 to latest (21.2.1) and got this error for all my tests:

 FAIL  tests\helpers\validator.test.js
  ● Test suite failed to run

    Cannot find module 'babel-core'

      at Function.Module._resolveFilename (module.js:536:15)
      at Function.Module._load (module.js:466:25)
      at Module.require (module.js:579:17)
      at require (internal/module.js:11:18)

Strange thing is that babel-core (v 6.26.0) is installed and listed in my package.json file.
Rolling back to 20.x solves the problem. I see that there are a lot of similar issues but they all seems related to babel v7, while I've problems with babel v6.

@thymikee
Copy link
Collaborator

This is most probably related to your package manager, not Jest. I'll close this but feel free to discuss.

@ingro
Copy link
Author

ingro commented Nov 15, 2017

By package manager you mean yarn? I also tried to install dependencies with npm after a full clean of node_modules folder but got the same results.

@luan03
Copy link

luan03 commented Feb 19, 2018

I have the same issue, also I've tried to change jest version and babel-core without any success so, I'll try to figure out why and then post here.

@JasonJJFS
Copy link

I have the same issue as well.

@luan03
Copy link

luan03 commented Mar 14, 2018

Hi @JasonJJFS,

I did these changes above and worked, not as I was expecting but worked:

I've created a .babelrc file and included this:

{
    "presets": ["@babel/preset-env","@babel/preset-react"]
}

Then, in my package.json file, I removed the node "presets": []

This worked for me and I hope that can help you.

@demsking
Copy link

I have the same issue and there are my project doesn't use babel. I just have standard and jest as dependencies.

chood531 added a commit to chood531/laravel-mix-purgecss that referenced this issue Sep 18, 2018
@lokers
Copy link

lokers commented Jan 8, 2019

add to package.json

"devDependencies": {
  "babel-core": "^7.0.0-bridge.0"
}

create empty file named /babel.config.js

add to .babelrc to presets:
"@babel/preset-env"

@petejodo
Copy link

if you build babel-jest on master the built output is correctly requiring @babel/core but [email protected] built output requires babel-core so somewhere between that release and master, the build process changed but I can't find anything in the changelog that mentions it. This should be fixed once the next release of jest occurs at least.

@SimenB
Copy link
Member

SimenB commented Jan 15, 2019

In the changelog:

[*] [BREAKING] Upgrade to Babel 7, dropping support for Babel 6 (#7016)

@SimenB
Copy link
Member

SimenB commented Jan 15, 2019

But as long as you install babel-core@bridge jest will use babel 7 even on jest 22 and 23

@LuoReid
Copy link

LuoReid commented Apr 2, 2019

add to package.json

"devDependencies": {
  "babel-core": "^7.0.0-bridge.0"
}

create empty file named /babel.config.js

add to .babelrc to presets:
"@babel/preset-env"

Thank you very much, It works :)

@bluedistro
Copy link

Installing babel-core bridge did the trick for me. Thanks

@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 11, 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

10 participants