redux - 获取 '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
有人可以指出我缺少什么吗?
解决方案
推荐阅读
- python - 理解字典的这个用例
- sql - 将 SELECT 语句中的值存储到 SQL Server 上的变量中
- java - 将十进制转换为任何基础java
- javascript - Window.open 并检查相同的 div 内容
- spring-boot - 防止需要使用 oauth2 重新登录 Angular6/Spring Boot 2 Web 应用程序
- python-3.x - python 3中标识符中的特殊字符
- azure - 是否可以将 MQ 客户端与安装在 Azure 应用服务中的 Web 应用一起使用?
- encryption - 是否存在看起来像“标准”通信而不是密码输出的加密方法?
- javascript - 如何获得所有票价的总和
- android-studio - 如何在whatsapp上从firebase发送音频文件