Friday, August 18, 2017

Error when running webpack

I had the following code:

webpack.config.js
module.exports = {
entry: './public/app.jsx',
output: {
path: __dirname,
filename: './public/bundle.js'
},
resolve: {
extensions: ['','.js','.jsx']
},
module: {
loaders: [
{
loader: 'babel-loader',
query: {
presets: ['react', 'es2015']
},
test: /\.jsx?$/,
exclude: /(node_modules|bower_components)/
}
]
}
};

package.json
{
"name": "hello-react",
"version": "1.0.0",
"description": "Simple react app",
"main": "index.js",
"scripts": {
"test": "echo \"Error: no test specified\" && exit 1"
},
"author": "Alina",
"license": "MIT",
"dependencies": {
"express": "^4.15.4",
"react": "^0.14.7",
"react-dom": "^0.14.7"
},
"devDependencies": {
"babel-core": "^6.26.0",
"babel-loader": "^7.1.1",
"babel-preset-es2015": "^6.5.0",
"babel-preset-react": "^6.5.0",
"webpack": "^1.12.13"
}
}


When running webpack in command line I was getting this error

Version: webpack 1.12.13
Time: 1394ms
    + 1 hidden modules

ERROR in ./public/app.jsx
Module build failed: Error: Plugin 19 specified in "D:\\Projects\\HelloReact\\node_modules\\babel-preset-es2015\\index.js" provided an invalid property of "name"
    at Plugin.init (D:\Projects\HelloReact\node_modules\babel-core\lib\transformation\plugin.js:127:13)
    at Function.normalisePlugin (D:\Projects\HelloReact\node_modules\babel-core\lib\transformation\file\options\option-manager.js:176:12)
    at D:\Projects\HelloReact\node_modules\babel-core\lib\transformation\file\options\option-manager.js:210:30
    at Array.map (native)
    at Function.normalisePlugins (D:\Projects\HelloReact\node_modules\babel-core\lib\transformation\file\options\option-manager.js:182:20)
    at OptionManager.mergeOptions (D:\Projects\HelloReact\node_modules\babel-core\lib\transformation\file\options\option-manager.js:298:36)
    at D:\Projects\HelloReact\node_modules\babel-core\lib\transformation\file\options\option-manager.js:370:14
    at D:\Projects\HelloReact\node_modules\babel-core\lib\transformation\file\options\option-manager.js:390:24
    at Array.map (native)
    at OptionManager.resolvePresets (D:\Projects\HelloReact\node_modules\babel-core\lib\transformation\file\options\option-manager.js:385:20)
    at OptionManager.mergePresets (D:\Projects\HelloReact\node_modules\babel-core\lib\transformation\file\options\option-manager.js:369:10)
    at OptionManager.mergeOptions (D:\Projects\HelloReact\node_modules\babel-core\lib\transformation\file\options\option-manager.js:328:14)
    at OptionManager.init (D:\Projects\HelloReact\node_modules\babel-core\lib\transformation\file\options\option-manager.js:481:10)
    at File.initOptions (D:\Projects\HelloReact\node_modules\babel-core\lib\transformation\file\index.js:211:75)
    at new File (D:\Projects\HelloReact\node_modules\babel-core\lib\transformation\file\index.js:129:22)
    at Pipeline.transform (D:\Projects\HelloReact\node_modules\babel-core\lib\transformation\pipeline.js:48:16)
    at transpile (D:\Projects\HelloReact\node_modules\babel-loader\index.js:14:22)
    at Object.module.exports (D:\Projects\HelloReact\node_modules\babel-loader\index.js:88:12)

Solution(that worked for me): Upgrade babel-core and babel-loader

npm install --save babel-core@latest babel-loader@latest

Running webpack went smoothly after that.

Source: https://stackoverflow.com/questions/35395881/plugin-0-specified-in-babel-preset-es2015-provided-an-invalid-property-of-c

No comments:

Post a Comment