我通过npm安装了模块“ koa-cache-control”。 我在index.js中添加了以下几行。
const cacheControl = require('koa-cache-control');
然后...
app.use(cacheControl({
noCache: true
}));
这是启动节点时遇到的错误。 有任何线索吗?
AssertionError: app.use() requires a generator function
at Application.app.use
(/home/www/node_modules/koa/lib/application.js:106:5)
at Object.<anonymous> (/home/www/index.js:17:5)
at Module._compile (module.js:570:32)
at Object.Module._extensions..js (module.js:579:10)
at Module.load (module.js:487:32)
at tryModuleLoad (module.js:446:12)
at Function.Module._load (module.js:438:3)
at Module.runMain (module.js:604:10)
at run (bootstrap_node.js:389:7)
at startup (bootstrap_node.js:149:9)
谢谢!
答案 0 :(得分:2)
您似乎正在使用旧版本的Koa。 1.x版本使用基于生成器的中间件类型,在第二版中将其更改为Promises。
您将不得不更新Koa或使用1.0.0
的旧版本koa-cache-control
。