这通常是由于没有正确安装必要的babel相关的模块导致的。可以尝试以下步骤解决此问题:
npm ls babel-loader @babel/core @babel/preset-react
如果没有安装,可以运行以下命令进行安装:
npm install --save-dev babel-loader @babel/core @babel/preset-react
npm cache clean --force
rm -rf node_modules
npm install
{
test: /\.js$/,
exclude: /node_modules/,
use: {
loader: 'babel-loader',
options: {
presets: ['@babel/preset-react']
}
}
}
然后再次运行npm start命令,应该可以成功编译React应用。
下一篇:编译日期库时出现很多警告