unexpected token error when npm start - react/webpack

一笑奈何 提交于 2019-12-11 19:06:08

问题


just tried creating my first react application, following this tutorial I found online: http://jmfurlott.com/tutorial-setting-up-a-single-page-react-web-app-with-react-router-and-webpack/. However I've run into a problem after completing it. I keep getting this error when I do an 'npm start' in the command line:

Module build failed: SyntaxError: /Users/ryan.garrett/Documents/myExample/js/app.js: Unexpected token (10:6)

Error is found on line 10 which is:

<div className="nav">

The full version is this:

import React from 'react';
import Router from 'react-router';
import { DefaultRoute, Link, Route, RouteHandler } from 'react-router';

import LoginHandler from './components/Login.js';

let App = React.createClass({
  render: function() {
    return (
      <div className="nav">
        <Link to="app">Home</Link>
        <Link to="login">Login</Link>

        {/* this is the importTant part */}
        <RouteHandler/>
      </div>
    );
  }
});

let routes = (
  <Route name="app" path="/" handler={App}>
    <Route name="login" path="/login" handler={LoginHandler}/>
  </Route>
);

Router.run(routes, function (Handler) {
  React.render(<Handler/>, document.body);
});

来源:https://stackoverflow.com/questions/34316456/unexpected-token-error-when-npm-start-react-webpack

易学教程内所有资源均来自网络或用户发布的内容,如有违反法律规定的内容欢迎反馈
该文章没有解决你所遇到的问题?点击提问,说说你的问题,让更多的人一起探讨吧!