我想告诉你我的问题。
我的环境:
Node: 8.9.1
npm: 5.6.0
yarn: 1.3.2
包.json
"devDependencies": {
"babel-core": "^6.26.0",
"babel-loader": "^7.1.2",
"babel-plugin-transform-object-rest-spread": "^6.26.0",
"babel-preset-env": "^1.6.1",
"babel-preset-react": "^6.24.1",
"copy-webpack-plugin": "^4.1.1",
...
"webpack": "^3.7.1",
"webpack-dev-server": "^2.9.2"
},
webpack.config.js
...
module: {
rules: [
{
test: /\.(js|jsx)$/,
exclude: /node_modules/,
use: {
loader: 'babel-loader',
options: {
cacheDirectory: true,
presets: ['react', 'env']
}
}
},
...
它总是编译失败,就像 {...}
./src/flux/components/BaseComponent.js module构建失败:语法错误:D:/APPs/src/flux/components/BaseComponent.js:意外令牌 (36:29)
34 | let {search} = this.state; 35 | search.includeActive = !search.includeActive; > 36 | this.setState({category : {...this.state.category, name : name}}); |
但是,它在没有 webpack 的情况下运行良好。请帮我解决这个问题!非常感谢你们所有人!:)