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' #124

Closed
DamienCassou opened this issue Aug 29, 2017 · 29 comments
Closed

Cannot find module 'babel-core' #124

DamienCassou opened this issue Aug 29, 2017 · 29 comments

Comments

@DamienCassou
Copy link

I've just updated from 6.1.2 to 7.0.0 and I now get this error message:

[17:08:05] 'requirejs' errored after 68 ms
[17:08:05] Error: Cannot find module 'babel-core'
    at Function.Module._resolveFilename (module.js:469:15)
    at Function.Module._load (module.js:417:25)
    at Module.require (module.js:497:17)
    at require (internal/module.js:20:19)
    at Object.<anonymous> (/.../Client/node_modules/gulp-babel/index.js:7:15)
    at Module._compile (module.js:570:32)
@abbassiddiqi
Copy link

abbassiddiqi commented Sep 4, 2017

Install babel-core as your dev dependency and it will work.

npm install --save-dev babel-core babel-preset-env

Update

As of babel 7, install the dependency via the following command instead

npm install --save-dev @babel/core @babel/preset-env

@loganfsmyth
Copy link
Member

The messaging from npm probably isn't super obvious, but yeah this was a change in 7.0. babel-core is now expected to be a peer dependency. When I install it on my machine for instance:

$ npm i gulp-babel
/private/tmp
├── UNMET PEER DEPENDENCY babel-core@6 || 7 || ^7.0.0-alpha || ^7.0.0-beta || ^7.0.0-rc
└─┬ gulp-babel@7.0.0 
 
<<  a bunch of stuff I removed  >>

npm WARN gulp-babel@7.0.0 requires a peer of babel-core@6 || 7 || ^7.0.0-alpha || ^7.0.0-beta || ^7.0.0-rc but none was installed.

which tries to convey this, but unless you're looking for it, it's pretty easy to miss.

@DamienCassou
Copy link
Author

Thank you, this worked. The release notes say:

made babel-core a peerDependency instead of dependency and supports v6/v7/(alpha/beta/rc for v7)

could you please make it a bit more explicit that something is required from the users? A note in the README would be nice as well.

@dduvanpantoja
Copy link

Thanks @abbassiddiqi,Thanks, but why I have to install this module by separated.

@sylbru
Copy link

sylbru commented Jan 31, 2018

The Setup page in the docs on babeljs.io doesn't mention this either:

npm install --save-dev gulp-babel

@demurgos
Copy link
Member

Agreed, the setup page should be updated.
The npm page (for 7.0.1) and Github README (for the beta version) are up-to-date so I recommend to check them.

@Duvan01
Having babel as a peer dependencies allows the main project to pick the version of Babel it wants without waiting for gulp-babel to be updated. Still, I'd prefer it to work out-of-the box. We may consider a setup where a default Babel is provided but you can supply your own version too.

@zaojiahua
Copy link

zaojiahua commented Mar 15, 2018

Install babel-core as your dev dependency and it will work.

this not works for me.

@zaojiahua
Copy link

The messaging from npm probably isn't super obvious, but yeah this was a change in 7.0. babel-core is now expected to be a peer dependency. When I install it on my machine for instance:

it works

@krshubham
Copy link

It wasn't working for me too, until I read the README.
It clearly says:
npm install --save-dev gulp-babel @babel/core @babel/preset-env
👍

@AlexanderKozhevin
Copy link

I keep getting an error on windows machine.

cannot find module 'babel-core'

@loganfsmyth
Copy link
Member

@AlexanderKozhevin When installing, you need to install that too: https://github.com/babel/gulp-babel/tree/v7-maintenance#install

@AlexanderKozhevin
Copy link

@loganfsmyth thanx!

shramee added a commit to shramee/gulp-sass-babel that referenced this issue May 23, 2018
`babel-core` is now expected to be a peer dependency. babel/gulp-babel#124
@lasalu99x
Copy link

I could fix it by this link

https://github.com/babel/babel-loader

@basickarl
Copy link

npm i @babel/core

@NhatNam98
Copy link

Thanks you so much

@gpresland
Copy link

Babel 6:

npm install --save-dev The following:

@babel/cli
@babel/core
@babel/preset-env

Babel 7:

npm install --save-dev The following:

babel-cli
babel-core
babel-preset-env

@primexpy
Copy link

primexpy commented Jan 1, 2019

@abbassiddiqi thank you very much!it worked

timneutkens pushed a commit to vercel/next.js that referenced this issue Jan 2, 2019
The current reasonml needs an example of how to do getInitialProps.  tmepple posted the only known way of doing it in [this comment](#4202 (comment)).   It is unlikely reasonml users are going to discover that comment or figure it out on their own so having it in an example is critical. 

Also, dependencies updated.  After updating dependencies, I get this error:
```
ModuleBuildError: Module build failed (from ./node_modules/next/dist/build/webpack/loaders/next-babel-loader.js):
[1] Error: Cannot find module '@babel/core'
[1]  babel-loader@8 requires Babel 7.x (the package '@babel/core'). If you'd like to use Babel 6.x ('babel-core'), you should install 'babel-loader@7'.
```
Seems like @babel/core is required as peer dependency per [this comment](babel/gulp-babel#124 (comment)) so I added it.

The way to do getInitialProps has changed in 7.0.2 canary so this also has a comment in the code about what change is required to get that working.
@SamuSan
Copy link

SamuSan commented Mar 12, 2019

Babel 6:

npm install --save-dev The following:

@babel/cli
@babel/core
@babel/preset-env

Babel 7:

npm install --save-dev The following:

babel-cli
babel-core
babel-preset-env

For anyone finding themselves down this rabbit hole, this comment is the exact opposite of reality. Babel 7 moved to the @babel namespace.

@luku
Copy link

luku commented Mar 26, 2019

For me the only working solution for Babel 7 was from Babel setup guide. Note the gulp-babel@next

npm install --save-dev gulp-babel@next @babel/core @babel/preset-env

@aggregate1166877
Copy link

Thought I'd add my own solution: delete package-lock.json and try again.

I have this issue crop up from time to time. Deleting package-lock.json solves it every time.

@anusharma9462
Copy link

still getiing the same error., please help me out. i tried
npm install --save-dev gulp-babel @babel/core @babel/preset-env
ERROR in ./app/dev/App.jsx
Module build failed: Error: Cannot find module 'babel-core'
at Function.Module._resolveFilename (internal/modules/cjs/loader.js:636:15)

sharing my package.json
{
"name": "CAP-offer-application",
"version": "2.8.23",
"description": "This is a React single-page-application that will dynamically render a variety of offers and tests on all CAP flows",
"author": "Ryan Wessel",
"license": "ISC",
"repository": {
"type": "git",
"url": "gitwebdev@awsgitwebdev.aws.synapsegroupinc.com:repos/webdev/webprod-cap.git"
},
"dependencies": {
"babel-loader": "^7.1.5",
"cli-color": "^2.0.0",
"colors": "^1.3.3",
"diff": "^4.0.1",
"file-loader": "^4.2.0",
"google-spreadsheet-to-json": "^1.0.0",
"gulp-template": "^5.0.0",
"html-webpack-plugin": "^3.0.6",
"i": "^0.3.6",
"lodash": "^4.17.5",
"mkdirp": "^0.5.1",
"modernizr": "^3.6.0",
"moment": "^2.24.0",
"npm": "^6.12.0",
"npm-check-updates": "^3.1.25",
"prop-types": "^15.6.1",
"puppeteer": "^1.14.0",
"react": "^16.8.6",
"react-dom": "^16.2.0",
"react-ga": "^2.4.1",
"react-graceful-unmount": "^1.0.7",
"react-iframe": "^1.8.0",
"react-loadable": "^5.3.1",
"react-onclickoutside": "^6.7.1",
"react-redux": "^7.1.1",
"react-router": "^5.1.2",
"react-router-dom": "^5.1.2",
"react-slick": "^0.25.2",
"redux": "^4.0.4",
"redux-thunk": "^2.2.0",
"scriptjs": "^2.5.8",
"slick-carousel": "^1.8.1",
"uglifyjs-webpack-plugin": "^2.2.0",
"url-loader": "^2.2.0",
"webpack": "^3.11.0",
"webpack-browser-plugin": "^1.0.20",
"webpack-dev-server": "^2.11.2",
"webpack-merge": "^4.1.2",
"whatwg-fetch": "^3.0.0",
"yargs": "^14.2.0"
},
"devDependencies": {
"@babel/cli": "^7.6.4",
"@babel/core": "^7.6.4",
"@babel/plugin-proposal-class-properties": "^7.5.5",
"@babel/preset-env": "^7.6.3",
"@babel/preset-react": "^7.6.3",
"babel-eslint": "^8.2.2",
"babel-minify": "^0.3.0",
"babel-plugin-syntax-dynamic-import": "^6.18.0",
"babel-polyfill": "^6.26.0",
"babel-preset-env": "^1.7.0",
"babel-preset-es2015": "^6.24.1",
"babel-preset-react": "^6.24.1",
"babel-preset-stage-2": "^6.24.1",
"babel-register": "^6.24.1",
"cross-env": "^6.0.3",
"css-loader": "^3.2.0",
"del": "^5.1.0",
"eslint": "^4.18.2",
"eslint-config-airbnb": "^16.1.0",
"eslint-plugin-import": "^2.9.0",
"eslint-plugin-jsx-a11y": "^6.0.3",
"eslint-plugin-react": "^7.7.0",
"gulp": "^3.9.1",
"gulp-awspublish": "^3.3.1",
"gulp-babel": "^7.0.1",
"gulp-bump": "^3.1.3",
"gulp-git": "^2.9.0",
"gulp-if": "^2.0.2",
"gulp-prompt": "^1.2.0",
"gulp-rename": "^1.2.2",
"json-loader": "^0.5.7",
"modernizr-loader": "^1.0.1",
"node-sass": "^4.7.2",
"path": "^0.12.7",
"prettier-eslint": "^8.8.2",
"react-hot-loader": "^4.0.0",
"sass-loader": "^8.0.0",
"style-loader": "^1.0.0",
"webpack-cli": "^3.3.9"
},
"scripts": {
"install": "npm run install-webpack-dev-server",
"install-webpack-dev-server": "npm install -g webpack webpack-dev-server",
"prebuild": "gulp clean && gulp bump",
"build": "cross-env NODE_ENV=production webpack --config webpack.prod.js",
"prepublish": "npm run build",
"publish": "gulp publish && gulp git",
"push": "npm run publish && gulp sync",
"start": "cross-env NODE_ENV=development webpack-dev-server --progress --inline --hot --config webpack.dev.js",
"split": "gulp react-split"
}
}

@lokesh14v
Copy link

I keep getting an error on windows machine.

cannot find module 'babel-core'

Just go inside the babel-loader and change the require("babel-core")----to ----require("@BabelCore")

@lokesh14v
Copy link

Install babel-core as your dev dependency and it will work.

npm install --save-dev babel-core babel-preset-env

Update

As of babel 7, install the dependency via the following command instead

npm install --save-dev @babel/core @babel/preset-env

After all,do this also .Just go inside the babel-loader and change the require("babel-core")----to ----require("@BabelCore")

@BananaNeil
Copy link

Thought I'd add my own solution: delete package-lock.json and try again.

I have this issue crop up from time to time. Deleting package-lock.json solves it every time.

Only this ^ worked for me.

@StevOmics
Copy link

Still not working. Thanks

@jdavis-software
Copy link

If you are using @babel-core (v7.0+) you need to upgrade to the latest version of babel-loader (v8.0) simply run this command.

npm install -D babel-loader@8.0.0

@ManuSquall
Copy link

If you are using @babel-core (v7.0+) you need to upgrade to the latest version of babel-loader (v8.0) simply run this command.

npm install -D babel-loader@8.0.0

Thanks @jdavis-software , this one work for me

@kimanicharles911
Copy link

Thought I'd add my own solution: delete package-lock.json and try again.
I have this issue crop up from time to time. Deleting package-lock.json solves it every time.

Only this ^ worked for me.

Then run npm i

@AllanOricil
Copy link

npm install --save-dev babel-core babel-preset-env

Did not work

image

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