I am running through a React tutorial and have hit this problem when I run npm run
on my project. The larger error code is:
ERROR in ./src/index.jsx Module build failed (from ./node_modules/babel-loader/lib/index.js): Error: Plugin/Preset files are not allowed to export objects, only functions. In /S8L27nodeproject/node_modules/babel-preset-react/lib/index.js
Looking at similar questions I thought my versions of Babel were not up-top-date, seeing as babel-loader
is a different version to the others, but when I run npm outdated
they appear fine.
My package.json file is:
{
"name": "s8l27nodeproject",
"version": "1.0.0",
"description": "",
"main": "index.js",
"scripts": {
"build": "webpack -p",
"start": "node ./node_modules/webpack-dev-server/bin/webpack-dev-server.js"
},
"author": "",
"license": "ISC",
"dependencies": {
"babel-core": "^6.26.3",
"babel-loader": "^8.0.4",
"babel-preset-es2015": "^6.24.1",
"babel-preset-react": "^6.24.1",
"babel-preset-stage-1": "^6.24.1",
"react": "^16.6.0",
"react-dom": "^16.6.0",
"webpack": "^4.25.1",
"webpack-dev-server": "^3.1.10"
},
"devDependencies": {
"@babel/core": "^7.1.5",
"webpack-cli": "^3.1.2"
}
}
Whilst my webpack.config.js file is:
module.exports = {
entry: [
'./src/index.jsx'
],
output: {
filename: './bundle.js'
},
module: {
rules: [{
exclude: /node_modules/,
loader: 'babel-loader'
}]
}
}
Would anyone know what I could do to fix this problem?