gpt4 book ai didi

javascript - 错误 : Couldn't find preset "es2015" relative to directory

转载 作者:数据小太阳 更新时间:2023-10-29 04:02:18 25 4
gpt4 key购买 nike

当我尝试使用 babel 时出现以下错误。

Error: Couldn't find preset "es2015" relative to directory

webpack.config.js

module.exports = {
entry: './main.js',
ourput: {
path:'./',
filename:'index.js'
},
devServer:{
inline:true,
port:3333
},
module:{
loaders:[
{
test:/\.js$/,
exclude:/node_modules/,
loader:'babel',
query:{
presets:['es2015','react']
}
}
]
}
}

包.json

{
"name": "es6-react-setup",
"version": "1.0.0",
"main": "main.js",
"dependencies": {
"babel-core": "^6.11.4",
"babel-preset-es2015": "^6.9.0",
"babel-preset-react": "^6.11.1",
"babel-loader": "^6.2.4",
"react": "^15.2.1",
"react-dom": "^15.2.1",
"webpack": "^1.13.1"
},
"devDependencies": {},
"scripts": {
"start": "webpack-dev-server"
},
"author": "",
"license": "ISC",
"description": ""
}

终端输出 Terminal output

最佳答案

您需要配置 babel 才能使用这些预设。您可以将其添加到您的 package.json

  "babel": {
"presets": [
"es2015",
"react"
]
},

你也可以有一个 .babelrc 文件。

https://babeljs.io/docs/usage/babelrc/

关于javascript - 错误 : Couldn't find preset "es2015" relative to directory,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/38474327/

25 4 0
Copyright 2021 - 2024 cfsdn All Rights Reserved 蜀ICP备2022000587号
广告合作:1813099741@qq.com 6ren.com