首页 > 解决方案 > 获取 'bundle.js:1 Uncaught SyntaxError: Unexpected token '<' in react/redux app

问题描述

我正在尝试从 Wes Bos 的网站学习 redux:https ://courses.wesbos.com/account并且我正在尝试跟随他的课程。但是,即使完全按照他在屏幕上的内容进行操作,我也会遇到错误。我有 2 个文件 - Main.js 和 reduxstagram.js。我的 Main.js 如下:

    import React from 'react';
    import { Link } from 'react-router';

    const Main = React.createClass({
      render(){
         return(
            <div>
             <h1>
                <Link to="/">Reduxstagram</Link>
            </h1>
           </div>
         )
        }
       })

     export default Main;

我的 reduxstagram.js 如下:

    // let's go!
    import React from 'react';
    import { render } from 'react-dom';

     //import css
     import css from './styles/style.styl';

      //import components
      import Main from './components/Main';

      render(<Main/>, document.getElementById('root'));

但是,当我尝试使用“npm start”呈现页面时,出现以下错误:

     bundle.js:1 Uncaught SyntaxError: Unexpected token '<' in 
     react/redux app

控制台给出以下错误:

     ERROR in ./components/Main.js
    Module parse failed: /Users/myUser/Downloads/Learn-Redux-Starter- 
     Files-master/learn-redux/components/Main.js Unexpected token 
       (7:12)
       You may need an appropriate loader to handle this file type.
        SyntaxError: Unexpected token (7:12)
        at Parser.pp$4.raise (/Users/myUser/Downloads/Learn-Redux- 
          Starter-Files-master/learn- 


  redux/node_modules/webpack/node_modules/acorn/dist/acorn.js:2221:15)
    at Parser.pp.unexpected (/Users/myUser/Downloads/Learn-Redux- 
        Starter-Files-master/learn- 

  redux/node_modules/webpack/node_modules/acorn/dist/acorn.js:603:10)
  at Parser.pp$3.parseExprAtom (/Users/myUser/Downloads/Learn-Redux- 
       Starter-Files-master/learn- 

 redux/node_modules/webpack/node_modules/acorn/dist/acorn.js:1822:12)
     at Parser.pp$3.parseExprSubscripts 
   (/Users/myUser/Downloads/Learn-Redux-Starter-Files-master/learn- 
   redux/node_modules/webpack/node_modules/acorn/dist/acorn.js:1715:21)
     at Parser.pp$3.parseMaybeUnary 
     (/Users/myUser/Downloads/Learn-Redux-Starter-Files-master/learn- 

   redux/node_modules/webpack/node_modules/acorn/dist/acorn.js:1692:19)
        at Parser.pp$3.parseExprOps 
      (/Users/myUser/Downloads/Learn-Redux-Starter-Files-master/learn- 


  redux/node_modules/webpack/node_modules/acorn/dist/acorn.js:1637:21)
      at Parser.pp$3.parseMaybeConditional 
   (/Users/myUser/Downloads/Learn-Redux-Starter-Files-master/learn- 
   redux/node_modules/webpack/node_modules/acorn/dist/acorn.js:1620:21)
    at Parser.pp$3.parseMaybeAssign (/Users/myUser/Downloads/Learn- 
    Redux-Starter-Files-master/learn- 
   redux/node_modules/webpack/node_modules/acorn/dist/acorn.js:1597:21)
  at Parser.pp$3.parseParenAndDistinguishExpression 
    (/Users/myUser/Downloads/Learn-Redux-Starter-Files-master/learn- 
   redux/node_modules/webpack/node_modules/acorn/dist/acorn.js:1861:32)
  at Parser.pp$3.parseExprAtom (/Users/myUser/Downloads/Learn-Redux- 
   Starter-Files-master/learn- 

   redux/node_modules/webpack/node_modules/acorn/dist/acorn.js:1796:19)
   @ ./client/reduxstagram.js 13:12-41

有人可以指出我缺少什么吗?

标签: reduxreact-redux

解决方案


推荐阅读