babel / gulp-babel

Gulp plugin for Babel
https://babeljs.io
MIT License
1.32k stars 120 forks source link

Cannot find module 'babel-core' #124

Closed DamienCassou closed 7 years ago

DamienCassou commented 7 years ago

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 commented 7 years ago

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 commented 7 years ago

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 commented 7 years ago

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 commented 6 years ago

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

sylbru commented 6 years ago

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

npm install --save-dev gulp-babel

demurgos commented 6 years ago

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 commented 6 years ago

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

this not works for me.

zaojiahua commented 6 years ago

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 commented 6 years ago

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 commented 6 years ago

I keep getting an error on windows machine.

cannot find module 'babel-core'
loganfsmyth commented 6 years ago

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

AlexanderKozhevin commented 6 years ago

@loganfsmyth thanx!

lasalu99x commented 6 years ago

I could fix it by this link

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

basickarl commented 6 years ago

npm i @babel/core

NhatNam98 commented 6 years ago

Thanks you so much

gpresland commented 5 years ago

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 commented 5 years ago

@abbassiddiqi thank you very much!it worked

SamuSan commented 5 years ago

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 commented 5 years ago

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 commented 5 years ago

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 commented 5 years ago

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 commented 4 years ago

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 commented 4 years ago

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 commented 4 years ago

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 commented 4 years ago

Still not working. Thanks

jdavis-software commented 4 years ago

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 commented 3 years ago

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 commented 3 years ago

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 commented 3 years ago
npm install --save-dev babel-core babel-preset-env

Did not work

image

mastershifu24 commented 2 months ago

Did anyone find a solution for this? I've been getting this error a lot: Parsing error: Cannot find module 'next/babel' Require stack:

Make sure that all the Babel plugins and presets you are using are defined as dependencies or devDependencies in your package.json file. It's possible that the missing plugin is loaded by a preset you are using that forgot to add the plugin to its dependencies: you can workaround this problem by explicitly adding the missing package to your top-level package.json.