dva使用yarn编译出错
1. 报错信息
./src/models/example.jsModule build failed: TypeError: /Users/user/Desktop/learn-code/10.React/01_dva-came/src/models/example.js: path.isPrivate is not a function at Array.forEach ()
只要启动项目,然后修改example代码,只要example发生改变就会报该错误,无论是添加注释还是产生新的换行
2.原始代码
// example.js
import { routerRedux } from "dva/router";
// routerRedux == connected-react-redux
function delay(ms) {
return new Promise((resolve) => {
setTimeout(() => {
resolve();
}, ms);
});
}
export default {
namespace: "counter",
state: {
count: 1,
},
//ddd
subscriptions: {
setup({ dispatch, history }) {
// eslint-disable-line
},
},
effects: {
*asyncAdd(action, { put, call }) {
yield call(delay, 1000);
yield put({ type: "counter/add" });
},
*goto({ payload }, { put }) {
yield put(routerRedux.push(payload));
},
},
reducers: {
add(state, action) {
console.log("state", state);
return {
count: state.count + 1,
};
},
},
};
// index.js
import dva, { connect } from "dva";
import { Router, Route } from "dva/router";
import React from "react";
import "./index.css";
console.log("Router", Route);
// 1. Initialize
const app = dva();
// 2. Plugins
// app.use({});
// 3. Model
app.model(require("./models/example").default);
// 4. Router
// app.router(require("./router").default);
let Counter = connect((state) => state.counter)((props) => {
let { count, dispatch } = props;
console.log("count", props);
return (
<div>
<p>{count}</p>
<button
onClick={() =>
dispatch({
type: "counter/add",
})
}
>
+
</button>
<button onClick={() => dispatch({ type: "counter/asyncAdd" })}>
async +
</button>
<button onClick={() => dispatch({ type: "counter/goto", payload: "/" })}>
goto /
</button>
</div>
);
});
const Home = (props) => <div>home</div>;
app.router(({ history }) => (
<Router history={history}>
{/* Router 下面只能有一个元素 */}
<React.Fragment>
<Route path="/" exact component={Home} />
<Route path="/counter" component={Counter} />
</React.Fragment>
</Router>
));
// 5. Start
app.start("#root");
3.最终查找原因
- 并没有找到具体是因为什么,猜测原因是使用了yarn 重新安装依赖导致
- 如果重新使用npm 安装依赖则恢复正常
++++++++++++++++++++++++++++++++++++++++++++++
经过测试发现,使用dva脚手架生成的项目如果后期使用了yarn安装依赖,就会导致出现该错误
dva使用yarn编译出错的更多相关文章
- Android Studio2.1.2 Java8环境下引用Java Library编译出错
转载请注明出处:http://www.cnblogs.com/LT5505/p/5685242.html 问题:在Android Studio2.1.2+Java8的环境下,引用Java Librar ...
- protobuf编译出错的解决方案(iOS,OSX)
protobuf 最近使用protobuf,变编译工具时遇上一点问题.现在附上解决方案 编译过程 完全参照 https://github.com/alexeyxo/protobuf-objc 编译出错 ...
- Xamarin.iOS编译出错
Xamarin.iOS编译出错 错误信息:C:/Program Files(x86)/Reference Assemblies/Microsoft/Framework/Xamarin.iOS/v1.0 ...
- Cocos2d-x 3.0 编译出错 解决 error: expected ';' at end of member declaration
近期把项目移植到cocos2d-x 3.0,在整Android编译环境的时候,出现一大堆的编译出错,都是类似"error: expected ';' at end of member dec ...
- Weblogic jsp页面编译出错,Weblogic jsp编译异常
Weblogic jsp页面编译出错,Weblogic jsp编译异常 ======================== 蕃薯耀 2018年1月29日 http://www.cnblogs.com/f ...
- 关于Koala 中文编译出错
关于koala: 我们知道koala是一个前端预处理器语言图形编译工具,支持Less.Sass.Compass.CoffeeScript,帮助web开发者更高效地使用它们进行开发.跨平台运行,完美兼容 ...
- codeblocks c++ 编译出错
codeblocks编译出错 今天编译一个c++程序调用模板的时候,出现错误 error This file requires compiler and library support for the ...
- gcc编译出错---make[5]: *** [s-attrtab] Killed
内存不足导致的编译出错,解决方法是增加swapfile. root@ubuntu:home# swapon -s Filename Type Size Used ...
- 关于使用Google Analyse导入库文件编译出错的解决办法.
(最新解决办法):因为要通过cocoapod链接库,那么直接在Podfile上面加上 pod 'GoogleAnalytics-iOS-SDK', '~> 3.0.9',然后在pod insta ...
- STM32F103RB, KEIL编译出错:cannot open preprocessing output output file ".\神舟i号\main.d" no such file or
STM32F103RB, KEIL编译出错:cannot open preprocessing output output file ".\神舟i号\main.d" no su ...
随机推荐
- WEBRTC回声消除-AECM算法源码解析之参数解析
一 概述 webrtc 针对回声问题一共开源了3种回声消除算法,分别为aec,aecm,以及aec3,其中aec是最早期的版本,在后续的更新中aec3的出现代替了aec在webrtc 中的地位,而 ...
- day28--Java泛型01
Java泛型01 1.泛型的理解和好处 看一个需求: 请编写程序,在ArrayList中添加三个Dog对象 Dog对象含有name和age,并输出name和age(要求使用getXXX()) 先用传统 ...
- jprofiler注册码共享
name和company随意,license如下: L-Larry_Lau@163.com#36573-fdkscp15axjj6#25257 L-Larry_Lau@163.com#5481-ucj ...
- python学习笔记(3):模块
模块 一个.py文件就是一个模块,模块可以包含在包(package)内.包内必须有一个__init**__**.py,包也可以多层嵌套.__init__.py也是一个模块,模块名就是包名. 当用命令行 ...
- Qt HTTP网络相关GET,POST(HTTP 模拟POST 表单(multipartform)最简单和正式的方法)
PS:要转载请注明出处,本人版权所有. PS: 这个只是基于<我自己>的理解, 如果和你的原则及想法相冲突,请谅解,勿喷. 前置说明 本文作为本人csdn blog的主站的备份.(Bl ...
- 记录--源码视角,Vue3为什么推荐使用ref而不是reactive
这里给大家分享我在网上总结出来的一些知识,希望对大家有所帮助 ref 和 reactive 是 Vue3 中实现响应式数据的核心 API.ref 用于包装基本数据类型,而 reactive 用于处理对 ...
- 不用写一行代码!Python最强自动化神器!
1.Playwright介绍 Playwright是一个由Microsoft开发的开源自动化测试工具,它可以用于测试Web应用程序.Playwright支持多种浏览器,包括Chrome.Firefox ...
- java 控制台 输出进度条
效果 代码 public static void main(String[] args) { int total = 100; for (int i = 0; i < total; i++) ...
- KingbaseES V8R6集群部署案例之---脚本部署节点环境检查故障
KingbaseES V8R6集群部署案例之---脚本部署节点环境检查故障 案例说明: KingbaseES V8R6集群在部署前会对集群节点系统环境进行检测,检测失败后,将中断部署:其中一个检测项, ...
- KingbaseES V8R6 集群运维系列--archive_cleanup_command参数应用
案例说明: 参数archive_cleanup_command可以配置在kingbase.conf文件中,用于备库清理不在需要的归档日志,参数详细说明见下图: https://postgresql ...