-
现象:nodejs中使用apidoc在控制台报如下错误:
require.
min.js:19 TypeError: Cannot read property 'Filter...' of undefined
at Object.__ (locale.js?v=1579071667889:35)
at Object.<anonymous> (handlebars_helper.js?v=1579071667889:43)
at Object.eval [as main] (eval at createFunctionContext (handlebars.min.js?v=1579071667889:28), <anonymous>:6:97)
at c (handlebars.min.js?v=1579071667889:27)
at d (handlebars.min.js?v=1579071667889:27)
at e (handlebars.min.js?v=1579071667889:28)
at main.js:295
at Object.execCb (require.min.js:30)
at ea.check (require.min.js:18)
at ea.<anonymous> (require.min.js:23)
页面显示为空白:

- 软件环境:
- apidoc 版本:0.19.1
- 操作系统 macOS 10.14.6
- Google chrome 版本 79.0.3945.117(正式版本)
- node v10.16.3
- 测试源代码
const Koa = require('koa');
const util = require('util');
const app = new Koa();
const helper = require('./helper');
let logger = helper.getLogger('logTest');
const router = require('koa-router')();
const handler = async (ctx, next) => {
try {
console.info("==>handler");
await next();
console.info("<==handler");
} catch (e) {
console.info('e.err:', e.err);
console.info('e.status:', e.status);
ctx.response.statusCode = e.status || e.err || 500;
ctx.response.body = 'errrrrrrrrr';
console.info("1<==handler");
console.log(e.message === 'file_not_found');
ctx.app.emit(e.message, new Error("log file can't be found"), ctx);
app.use(handler);
* @api {post} /api/User/register 用户注册
* @apiDescription 用户注册
* @apiName Register
* @apiGroup User
* @apiParam {string} name 用户名
* @apiParam {string} password 密码
* @apiVersion 1.0.0
app.use(router.get('/test', async ctx => {
console.log("test log");
ctx.throw(new Error(util.format('file_not_found:%s', 'asdfasdf')));
}).routes());
app.listen(3000);
console.log("ready for service");
app.on('file_not_found', (err, ctx) => {
logger.error("err:", err);
logger.info("--============================");
logger.error("%s, ctx:%j", err.stack, ctx);
});
"name": "koa-demos",
"version": "1.0.0",
"description": "a collection of simple demos of Koa",
"scripts": {
"dev": "cross-env NODE_ENV=dev nodemon demos/test/logtest.js",
"prod": "cross-env NODE_ENV=prod node demos/test/logtest.js",
"test": "echo \"Error: no test specified\" && exit 1"
"apidoc": {
"template": {
"forceLanguage": "zh-cn"
"title": "apiDoc在浏览器中的标题",
"url": "api.github.com/v1"
"keywords": [
"Koa",
"Node"
"author": "Li Yi",
"dependencies": {
"cross-env": "^6.0.3",
"express-validator": "^6.3.0",
"fs.promised": "^3.0.0",
"koa": "^2.3.0",
"koa-body": "^2.3.0",
"koa-bodyparser": "^4.2.1",
"koa-compose": "^4.0.0",
"koa-parameter": "^3.0.1",
"koa-route": "^3.2.0",
"koa-router": "^7.4.0",
"koa-schema": "0.0.1",
"koa-static": "^4.0.1",
"log4js": "^6.1.0"
"devDependencies": {
"apidoc": "^0.19.1",
"jsdoc": "^3.6.3"
// -i demos/test是测试文件所在的目录
// -f ".*\\.js$" 是用来指定要生成api的文件格式的
// -o ./apidoc是用来指定生成文件的目录的
apidoc -i demos/test -f ".*\\.js$" -o ./apidoc
在0.19.1版本中没有zh-cn这个编码了,得设置成为zh_cn。
之所以会设置成为这个错误的编码是因为在这篇博客中看到的教程设置的,现在版本迭代之后,zh-cn已经不能用了。
参见官方现有的locales
- 能看官网教程的时候还是尽量看官网的,毕竟网上散落的教程有可能过时了,但是官网的总会是最新的。。
- 大家在博客中写教程的时候,尽量带上软件的版本号信息,环境信息,不然容易误导人
解决nodejs中使用apidoc遇到的问题:Cannot read property 'Filter...' of undefined。在这里可以找到apidoc使用简体中文的正确打开方式,有代码为证
jQuery Cannot read property ‘msie’ of undefined错误的解决方法
最近把一个项目的jQuery升级到最新版,发现有些页面报如下错误
Cannot read property ‘msie’ of undefined
上jQuery网站上搜了一下,原因是$.browser这个api从jQuery1.9开始就正式废除,js代码里只要用到$.browser就会报这个错。具体说明参见jQuery官方说明。
楼主顺便扩展阅读了一下,发现jQuery 1.9把所有在之前版本里标记为deprecated的api都正式删除了,彻底不再向后兼容。对于升级到最新jQu
apidoc是一个简单的RESTful
API文档生成工具,它从代码注释 中提取特定格式的内容生成文档。支持诸如GO、Java、C++、Rust 等大部分开发语言。1.跨平台,linux. windows、 macOS等都支持;
2.支持语言广泛,即使是不支持,也很方便扩展;
3.支持多个不同语言的多个项目生成一份文档;
4.输出模板可自定义;
5.根据文档生成mock数据;eg:完成的注释:
生成文档命令:
执行命令生成的文档:
在浏览器打开index.html就可以查看生成的文档。
vue2 “Cannot read property ‘length’ of undefined”
最近在项目中总是遇见报错"length of undefined"的问题,因为项目的需要要显示存在的个数,所以通过length来进行求职
this.projectReportSumNum = val.reportArray.length;
虽然界面可以显示len...
经过修改 webpack 的 entry 及 HtmlWebpackPlugin 等配置后,出现如下报错:
这是因为将 webpack 的 entry 将原来的数组方式修改为了对象,自然没有 filter 方法。
解决方法
修改 entrypoints.main 中的 main 为你在 entry 中配置的项目首页的 key。我的 entry 配置中首页的 key 为 index ,因此可改为 entrypoints.index。
写第二篇之前,先说个事情。针对前面我写的
如何编写高质量的函数 -- 敲山震虎篇 文章的评论区,小伙伴提出的一些问题,我也全部都看了,特此写了答疑篇。
答疑篇放在了 issues 上,点击下面链接即可 TP :
如何编写高质量的函数 -- 敲山震虎的答疑篇
对我的回答...
这个错误的意思是在使用 Node.js 时找不到 highlight.js 这个库。这通常是因为你没有正确安装 highlight.js,或者在代码中没有正确引用 highlight.js。
要解决这个问题,你需要确保 highlight.js 已经正确安装,并在你的代码中正确引用了它。例如,如果你使用的是 npm 安装 highlight.js,可以在你的代码中使用以下语句引用它:
var hljs = require('highlight.js');
如果你使用的是其他方式安装 highlight.js,请确保你在代码中正确引用了 highlight.js。
Thread.sleep(1000*10);
} catch (InterruptedException e) {
// TODO Auto-generated catch block
e.printStackTrace();
Log4J2(五) - 配置文件是怎么获取的?
即将奔跑的蜗牛:
Log4J2(五) - 配置文件是怎么获取的?
MrMoving:
使用javax.swing.Timer遇到的问题(已解决)。
qq_53826890:
Node.js redis client用什么? 需要使用redis连接池么?
康康来了: