Creating a library with webpack/babel 7, and getting Module build failed: Error: Requires Babel...












1















I'm trying to build a library using webpack 4/babel 7, I'm able to export everything properly to a new create-react-app as it uses babel 7.
But when I'm importing the library to a repository that uses babel 6 I get this



error



"Module build failed: Error: Requires Babel "^7.0.0-0", but was loaded with "6.26.0". If you are sure you have a compatible version of @babel/core, it is likely that something in your build process is loading the wrong version. Inspect the stack trace of this error to look for the first entry that doesn't mention "@babel/core" or "babel-core" to see what is calling Babel.
at Array.map ()"



Is there a way to make this work without having the proper babel version for the project that will be importing specific utils from this library?



Shouldn't the build process use babel7 to compile everything so the importing library can use it even with other versions of babel?



webpack.config.js



const path = require("path");

module.exports = {
entry: "./src/index.js",
module: {
rules: [
{
test: /.(js|jsx)$/,
exclude: /node_modules/,
use: {
loader: "babel-loader",
},
},
],
},
output: {
path: path.resolve(__dirname, "dist"),
filename: "Utils.js",
library: "Utils",
libraryTarget: "umd",
},
target: "node",
externals: {},
};


.babelrc



{
"presets": ["@babel/preset-env", "@babel/preset-react"],
"plugins": ["@babel/plugin-proposal-class-properties"]
}


dev dependencies of the library



  "devDependencies": {
"@babel/core": "^7.2.2",
"@babel/plugin-proposal-class-properties": "^7.2.3",
"@babel/preset-env": "^7.2.3",
"@babel/preset-react": "^7.0.0",
"babel-eslint": "^10.0.1",
"babel-loader": "^8.0.4",









share|improve this question




















  • 1





    Please include the full stack trace of the error.

    – loganfsmyth
    Jan 3 at 18:32











  • Babel moved from babel- to the scoped @babel package in v7(?). I'm guessing you'll need to replace babel-plugin-transform-class-properties to @babel/plugin-proposal-class-properties

    – Phix
    Jan 3 at 19:11











  • @Phix I do have the proper plugin as my second devDependency, and when it's removed the result is the same. Good catch though! I'll update dependencies

    – Jack Lye
    Jan 3 at 19:34











  • I'm running into this as well. Any updates? My expectation is that once the library is built for UMD, it shouldn't matter that it was transpiled with babel 7, but that doesn't seem to be the case.

    – wlabs
    Mar 13 at 15:12
















1















I'm trying to build a library using webpack 4/babel 7, I'm able to export everything properly to a new create-react-app as it uses babel 7.
But when I'm importing the library to a repository that uses babel 6 I get this



error



"Module build failed: Error: Requires Babel "^7.0.0-0", but was loaded with "6.26.0". If you are sure you have a compatible version of @babel/core, it is likely that something in your build process is loading the wrong version. Inspect the stack trace of this error to look for the first entry that doesn't mention "@babel/core" or "babel-core" to see what is calling Babel.
at Array.map ()"



Is there a way to make this work without having the proper babel version for the project that will be importing specific utils from this library?



Shouldn't the build process use babel7 to compile everything so the importing library can use it even with other versions of babel?



webpack.config.js



const path = require("path");

module.exports = {
entry: "./src/index.js",
module: {
rules: [
{
test: /.(js|jsx)$/,
exclude: /node_modules/,
use: {
loader: "babel-loader",
},
},
],
},
output: {
path: path.resolve(__dirname, "dist"),
filename: "Utils.js",
library: "Utils",
libraryTarget: "umd",
},
target: "node",
externals: {},
};


.babelrc



{
"presets": ["@babel/preset-env", "@babel/preset-react"],
"plugins": ["@babel/plugin-proposal-class-properties"]
}


dev dependencies of the library



  "devDependencies": {
"@babel/core": "^7.2.2",
"@babel/plugin-proposal-class-properties": "^7.2.3",
"@babel/preset-env": "^7.2.3",
"@babel/preset-react": "^7.0.0",
"babel-eslint": "^10.0.1",
"babel-loader": "^8.0.4",









share|improve this question




















  • 1





    Please include the full stack trace of the error.

    – loganfsmyth
    Jan 3 at 18:32











  • Babel moved from babel- to the scoped @babel package in v7(?). I'm guessing you'll need to replace babel-plugin-transform-class-properties to @babel/plugin-proposal-class-properties

    – Phix
    Jan 3 at 19:11











  • @Phix I do have the proper plugin as my second devDependency, and when it's removed the result is the same. Good catch though! I'll update dependencies

    – Jack Lye
    Jan 3 at 19:34











  • I'm running into this as well. Any updates? My expectation is that once the library is built for UMD, it shouldn't matter that it was transpiled with babel 7, but that doesn't seem to be the case.

    – wlabs
    Mar 13 at 15:12














1












1








1








I'm trying to build a library using webpack 4/babel 7, I'm able to export everything properly to a new create-react-app as it uses babel 7.
But when I'm importing the library to a repository that uses babel 6 I get this



error



"Module build failed: Error: Requires Babel "^7.0.0-0", but was loaded with "6.26.0". If you are sure you have a compatible version of @babel/core, it is likely that something in your build process is loading the wrong version. Inspect the stack trace of this error to look for the first entry that doesn't mention "@babel/core" or "babel-core" to see what is calling Babel.
at Array.map ()"



Is there a way to make this work without having the proper babel version for the project that will be importing specific utils from this library?



Shouldn't the build process use babel7 to compile everything so the importing library can use it even with other versions of babel?



webpack.config.js



const path = require("path");

module.exports = {
entry: "./src/index.js",
module: {
rules: [
{
test: /.(js|jsx)$/,
exclude: /node_modules/,
use: {
loader: "babel-loader",
},
},
],
},
output: {
path: path.resolve(__dirname, "dist"),
filename: "Utils.js",
library: "Utils",
libraryTarget: "umd",
},
target: "node",
externals: {},
};


.babelrc



{
"presets": ["@babel/preset-env", "@babel/preset-react"],
"plugins": ["@babel/plugin-proposal-class-properties"]
}


dev dependencies of the library



  "devDependencies": {
"@babel/core": "^7.2.2",
"@babel/plugin-proposal-class-properties": "^7.2.3",
"@babel/preset-env": "^7.2.3",
"@babel/preset-react": "^7.0.0",
"babel-eslint": "^10.0.1",
"babel-loader": "^8.0.4",









share|improve this question
















I'm trying to build a library using webpack 4/babel 7, I'm able to export everything properly to a new create-react-app as it uses babel 7.
But when I'm importing the library to a repository that uses babel 6 I get this



error



"Module build failed: Error: Requires Babel "^7.0.0-0", but was loaded with "6.26.0". If you are sure you have a compatible version of @babel/core, it is likely that something in your build process is loading the wrong version. Inspect the stack trace of this error to look for the first entry that doesn't mention "@babel/core" or "babel-core" to see what is calling Babel.
at Array.map ()"



Is there a way to make this work without having the proper babel version for the project that will be importing specific utils from this library?



Shouldn't the build process use babel7 to compile everything so the importing library can use it even with other versions of babel?



webpack.config.js



const path = require("path");

module.exports = {
entry: "./src/index.js",
module: {
rules: [
{
test: /.(js|jsx)$/,
exclude: /node_modules/,
use: {
loader: "babel-loader",
},
},
],
},
output: {
path: path.resolve(__dirname, "dist"),
filename: "Utils.js",
library: "Utils",
libraryTarget: "umd",
},
target: "node",
externals: {},
};


.babelrc



{
"presets": ["@babel/preset-env", "@babel/preset-react"],
"plugins": ["@babel/plugin-proposal-class-properties"]
}


dev dependencies of the library



  "devDependencies": {
"@babel/core": "^7.2.2",
"@babel/plugin-proposal-class-properties": "^7.2.3",
"@babel/preset-env": "^7.2.3",
"@babel/preset-react": "^7.0.0",
"babel-eslint": "^10.0.1",
"babel-loader": "^8.0.4",






javascript reactjs webpack babeljs babel






share|improve this question















share|improve this question













share|improve this question




share|improve this question








edited Jan 3 at 19:34







Jack Lye

















asked Jan 3 at 18:15









Jack LyeJack Lye

62




62








  • 1





    Please include the full stack trace of the error.

    – loganfsmyth
    Jan 3 at 18:32











  • Babel moved from babel- to the scoped @babel package in v7(?). I'm guessing you'll need to replace babel-plugin-transform-class-properties to @babel/plugin-proposal-class-properties

    – Phix
    Jan 3 at 19:11











  • @Phix I do have the proper plugin as my second devDependency, and when it's removed the result is the same. Good catch though! I'll update dependencies

    – Jack Lye
    Jan 3 at 19:34











  • I'm running into this as well. Any updates? My expectation is that once the library is built for UMD, it shouldn't matter that it was transpiled with babel 7, but that doesn't seem to be the case.

    – wlabs
    Mar 13 at 15:12














  • 1





    Please include the full stack trace of the error.

    – loganfsmyth
    Jan 3 at 18:32











  • Babel moved from babel- to the scoped @babel package in v7(?). I'm guessing you'll need to replace babel-plugin-transform-class-properties to @babel/plugin-proposal-class-properties

    – Phix
    Jan 3 at 19:11











  • @Phix I do have the proper plugin as my second devDependency, and when it's removed the result is the same. Good catch though! I'll update dependencies

    – Jack Lye
    Jan 3 at 19:34











  • I'm running into this as well. Any updates? My expectation is that once the library is built for UMD, it shouldn't matter that it was transpiled with babel 7, but that doesn't seem to be the case.

    – wlabs
    Mar 13 at 15:12








1




1





Please include the full stack trace of the error.

– loganfsmyth
Jan 3 at 18:32





Please include the full stack trace of the error.

– loganfsmyth
Jan 3 at 18:32













Babel moved from babel- to the scoped @babel package in v7(?). I'm guessing you'll need to replace babel-plugin-transform-class-properties to @babel/plugin-proposal-class-properties

– Phix
Jan 3 at 19:11





Babel moved from babel- to the scoped @babel package in v7(?). I'm guessing you'll need to replace babel-plugin-transform-class-properties to @babel/plugin-proposal-class-properties

– Phix
Jan 3 at 19:11













@Phix I do have the proper plugin as my second devDependency, and when it's removed the result is the same. Good catch though! I'll update dependencies

– Jack Lye
Jan 3 at 19:34





@Phix I do have the proper plugin as my second devDependency, and when it's removed the result is the same. Good catch though! I'll update dependencies

– Jack Lye
Jan 3 at 19:34













I'm running into this as well. Any updates? My expectation is that once the library is built for UMD, it shouldn't matter that it was transpiled with babel 7, but that doesn't seem to be the case.

– wlabs
Mar 13 at 15:12





I'm running into this as well. Any updates? My expectation is that once the library is built for UMD, it shouldn't matter that it was transpiled with babel 7, but that doesn't seem to be the case.

– wlabs
Mar 13 at 15:12












0






active

oldest

votes












Your Answer






StackExchange.ifUsing("editor", function () {
StackExchange.using("externalEditor", function () {
StackExchange.using("snippets", function () {
StackExchange.snippets.init();
});
});
}, "code-snippets");

StackExchange.ready(function() {
var channelOptions = {
tags: "".split(" "),
id: "1"
};
initTagRenderer("".split(" "), "".split(" "), channelOptions);

StackExchange.using("externalEditor", function() {
// Have to fire editor after snippets, if snippets enabled
if (StackExchange.settings.snippets.snippetsEnabled) {
StackExchange.using("snippets", function() {
createEditor();
});
}
else {
createEditor();
}
});

function createEditor() {
StackExchange.prepareEditor({
heartbeatType: 'answer',
autoActivateHeartbeat: false,
convertImagesToLinks: true,
noModals: true,
showLowRepImageUploadWarning: true,
reputationToPostImages: 10,
bindNavPrevention: true,
postfix: "",
imageUploader: {
brandingHtml: "Powered by u003ca class="icon-imgur-white" href="https://imgur.com/"u003eu003c/au003e",
contentPolicyHtml: "User contributions licensed under u003ca href="https://creativecommons.org/licenses/by-sa/3.0/"u003ecc by-sa 3.0 with attribution requiredu003c/au003e u003ca href="https://stackoverflow.com/legal/content-policy"u003e(content policy)u003c/au003e",
allowUrls: true
},
onDemand: true,
discardSelector: ".discard-answer"
,immediatelyShowMarkdownHelp:true
});


}
});














draft saved

draft discarded


















StackExchange.ready(
function () {
StackExchange.openid.initPostLogin('.new-post-login', 'https%3a%2f%2fstackoverflow.com%2fquestions%2f54027668%2fcreating-a-library-with-webpack-babel-7-and-getting-module-build-failed-error%23new-answer', 'question_page');
}
);

Post as a guest















Required, but never shown

























0






active

oldest

votes








0






active

oldest

votes









active

oldest

votes






active

oldest

votes
















draft saved

draft discarded




















































Thanks for contributing an answer to Stack Overflow!


  • Please be sure to answer the question. Provide details and share your research!

But avoid



  • Asking for help, clarification, or responding to other answers.

  • Making statements based on opinion; back them up with references or personal experience.


To learn more, see our tips on writing great answers.




draft saved


draft discarded














StackExchange.ready(
function () {
StackExchange.openid.initPostLogin('.new-post-login', 'https%3a%2f%2fstackoverflow.com%2fquestions%2f54027668%2fcreating-a-library-with-webpack-babel-7-and-getting-module-build-failed-error%23new-answer', 'question_page');
}
);

Post as a guest















Required, but never shown





















































Required, but never shown














Required, but never shown












Required, but never shown







Required, but never shown

































Required, but never shown














Required, but never shown












Required, but never shown







Required, but never shown







Popular posts from this blog

Mossoró

Error while reading .h5 file using the rhdf5 package in R

Pushsharp Apns notification error: 'InvalidToken'