错误:babel-loader @ 8需要Babel 7.x(软件包“ @ babel / core”)。如果您想使用Babel 6.x(“ babel-core”),则应安装“ babel-loader @ 7”。 尝试构建webpack.config.js文件时出现错误。
{
"name": "",
"version": "1.0.0",
"description": "create a graph out of a json object",
"main": "main.js",
"scripts": {
"start": "webpack-dev-server --entry ./main.js --output-filename ./dist/bundle.js",
"build": "webpack"
},
"author": "",
"license": "MIT",
"devDependencies": {
"babel-core": "^6.26.3",
"babel-loader": "^8.0.4",
"babel-preset-es2015": "^6.24.1",
"css-loader": "^1.0.1",
"style-loader": "^0.23.1",
"webpack": "^4.26.0",
"webpack-cli": "^3.1.2",
"webpack-dev-server": "^3.1.10"
},
"dependencies": {}
}
module.exports = {
mode: 'development',
entry: './main.js',
output: {
path: __dirname + '/dist',
filename: 'bundle.js'
},
module: {
rules: [
{
test: /\.css$/,
use: [
{loader: 'style-loader'},
{loader: 'css-loader'},
]
},
{
test: /\.js$/,
use:[
{
loader: 'babel-loader',
query: {
presets: ['es2015']
}
}
],
exclude: /node_modules/,
}
]
}
}
答案 0 :(得分:0)
您似乎需要更换
"babel-core": "^6.26.3"
使用
"@babel/core": "^7"