Module build failed (from ../../node_modules/@umijs/deps/compiled/babel-loader/index.js)
时间: 2023-11-22 08:05:25 浏览: 311
针对Module build failed (from ../../node_modules/@umijs/deps/compiled/babel-loader/index.js)错误,可以尝试以下解决方案:
1. 确认是否安装了@babel/core和@babel/preset-env,如果没有安装,可以执行以下命令进行安装:
```shell
npm install @babel/core @babel/preset-env --save-dev
```
2. 确认.babelrc文件是否正确配置,可以参考以下配置:
```json
{
"presets": [
[
"@babel/preset-env",
{
"targets": {
"browsers": ["last 2 versions", "safari >= 7"]
}
}
]
]
}
```
3. 确认webpack配置文件是否正确,可以参考以下配置:
```javascript
module: {
rules: [
{
test: /\.js$/,
exclude: /node_modules/,
use: {
loader: 'babel-loader',
options: {
presets: ['@babel/preset-env']
}
}
}
]
}
```
阅读全文