我是React + Webpack的新手.作为教程的一部分,我编写了一个webpack.config.js
文件.这是文件内容:
var webpack = require('webpack'); var path = require('path'); module.exports = { devtool: 'inline-source-map', entry: [ 'webpack-dev-server/client?http://localhost:8080/', 'webpack/hot/only-dev-server', './src' ], output: { path: path.join(__dirname, 'public'), filename: 'bundle.js' }, resolve:{ moduleDirectories: ['node_modules', 'src'], extensions: ['', '.js'] } module:{ loaders:[ { test: /\.jsx?$/, exclude: /node_modules/, loaders: ['react-hot','babel?presets[]=react,presets[]=es2015'] } ] }, plugins:[ new webpack.HotModuleReplacementPlugin(), new webpack.NoErrorsPlugin() ] };
我在第19->行遇到了意外的标识符错误 module:{...},
错误详情:
/home/adi/testcode/webpack.config.js:19 module:{ ^^^^^^ SyntaxError: Unexpected identifier at Object.exports.runInThisContext (vm.js:78:16) at Module._compile (module.js:543:28) at Object.Module._extensions..js (module.js:580:10) at Module.load (module.js:488:32) at tryModuleLoad (module.js:447:12) at Function.Module._load (module.js:439:3) at Module.require (module.js:498:17) at require (internal/module.js:20:19) at module.exports (/usr/lib/node_modules/webpack/bin/convert-argv.js:80:13) at Object.(/usr/lib/node_modules/webpack/bin/webpack.js:39:40)
我查了webpack.config.js
一些例子,发现我写的是正确的.但它并没有按预期工作.不幸的是,我无法在GitHub问题,StackOverflow和Quora中找到解决方案.
我哪里弄错了?
你在模块属性之前忘了一个逗号