根据react-route的例子写的代码,结果运行webpack webpack.config.js的时候,爆出了下面的错误。
ERROR in ./example/components/GlobalNav.js Module build failed: SyntaxError: /Users/eleme/workspace/UMNNSSG/example/components/GlobalNav.js: Unexpected token (29:22) 27 | class GlobalNav extends React.Component { 28 |
29 | static defaultProps = { | ^ 30 | user: { 31 | id: 1, 32 | name: ‘Ryan Florence’ at Parser.pp.raise (/Users/eleme/workspace/UMNNSSG/node_modules/babel-loader/node_modules/babel-core/node_modules/babylon/lib/parser/location.js:24:13) at Parser.pp.unexpected (/Users/eleme/workspace/UMNNSSG/node_modules/babel-loader/node_modules/babel-core/node_modules/babylon/lib/parser/util.js:82:8) at Parser.pp.parseClassProperty (/Users/eleme/workspace/UMNNSSG/node_modules/babel-loader/node_modules/babel-core/node_modules/babylon/lib/parser/statement.js:624:61) at Parser.parseClassProperty (/Users/eleme/workspace/UMNNSSG/node_modules/babel-loader/node_modules/babel-core/node_modules/babylon/lib/plugins/flow.js:797:20) at Parser.pp.parseClass (/Users/eleme/workspace/UMNNSSG/node_modules/babel-loader/node_modules/babel-core/node_modules/babylon/lib/parser/statement.js:567:32) at Parser.pp.parseStatement (/Users/eleme/workspace/UMNNSSG/node_modules/babel-loader/node_modules/babel-core/node_modules/babylon/lib/parser/statement.js:84:19) at Parser.parseStatement (/Users/eleme/workspace/UMNNSSG/node_modules/babel-loader/node_modules/babel-core/node_modules/babylon/lib/plugins/flow.js:621:22) at Parser.pp.parseTopLevel (/Users/eleme/workspace/UMNNSSG/node_modules/babel-loader/node_modules/babel-core/node_modules/babylon/lib/parser/statement.js:30:21) at Parser.parse (/Users/eleme/workspace/UMNNSSG/node_modules/babel-loader/node_modules/babel-core/node_modules/babylon/lib/parser/index.js:70:17) at Object.parse (/Users/eleme/workspace/UMNNSSG/node_modules/babel-loader/node_modules/babel-core/node_modules/babylon/lib/index.js:45:50) at Object.exports.default (/Users/eleme/workspace/UMNNSSG/node_modules/babel-loader/node_modules/babel-core/lib/helpers/parse.js:36:18) at File.parse (/Users/eleme/workspace/UMNNSSG/node_modules/babel-loader/node_modules/babel-core/lib/transformation/file/index.js:574:40) at File.parseCode (/Users/eleme/workspace/UMNNSSG/node_modules/babel-loader/node_modules/babel-core/lib/transformation/file/index.js:691:20) at /Users/eleme/workspace/UMNNSSG/node_modules/babel-loader/node_modules/babel-core/lib/transformation/pipeline.js:167:12 at File.wrap (/Users/eleme/workspace/UMNNSSG/node_modules/babel-loader/node_modules/babel-core/lib/transformation/file/index.js:639:16) at Pipeline.transform (/Users/eleme/workspace/UMNNSSG/node_modules/babel-loader/node_modules/babel-core/lib/transformation/pipeline.js:165:17) at transpile (/Users/eleme/workspace/UMNNSSG/node_modules/babel-loader/index.js:12:22) at Object.module.exports (/Users/eleme/workspace/UMNNSSG/node_modules/babel-loader/index.js:69:12) @ ./example/components/App.js 25:17-39
package.json文件如下 "dependencies": { "history": "^1.12.1", "react": "^0.13.3", "react-route": “^1.0.3” }, "devDependencies": { "babel": "^5.8.23", "babel-core": "^5.8.25", "babel-loader": "^5.3.2", "webpack": “^1.12.2” } node版本为v4.1.2