1.运行webpack报错
webpack命令 Error: Couldn't find preset @babel/preset-env
a,首先我得检查我有没有下载 babel-preset-env
npm install babel-preset-env --save-dev
b , 如果已经安装的话就去配置
以上就没啥问题了,有问题再根据问题百度
2,webpack运行错误2
You may need an appropriate loader to handle this file type.
render(){ return (> <h1>{text}</h1> ); }
我就检查,难道是我偶的js匹配的不明显么,再看我的源码配置
{ test: /\.js$/, loader: 'babel-loader', exclude: /node_modules/, query: { presets: ['react', 'es2015'] } }
于是看到问题了,jsx写成js了
{ test: /\.jsx?$/, exclude: /node_modules/, loader: 'babel-loader', query: { presets: ['react', 'es2015'] } }