unexpected token error when npm start - react/webp

2019-09-11 03:16发布

问题:

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);
});