[英]Possible issue with multer? Error: Router.use() requires callback
Building a site with yeoman angular-fullstack works great locally, but when I deploy and use the dist/release version it gives me this fun error on my server. 使用yeoman angular-fullstack构建一个站点在本地工作很好,但是当我部署并使用dist / release版本时,它在我的服务器上给了我这个有趣的错误。
Error: Router.use() requires callback functions but got a [object Object]
at Function.proto.use (/home/bitnami/htdocs/dist/node_modules/express/lib/router/index.js:327:11)
at Object.<anonymous> (/home/bitnami/htdocs/dist/server/api/save/index.js:10:8)
at Module._compile (module.js:460:26)
at Object.Module._extensions..js (module.js:478:10)
at Module.load (module.js:355:32)
at Function.Module._load (module.js:310:12)
at Function.<anonymous> (/opt/bitnami/nodejs/lib/node_modules/pm2/node_modules/pmx/lib/transaction.js:62:21)
at Module.require (module.js:365:17)
at require (module.js:384:17)
at module.exports (/home/bitnami/htdocs/dist/server/routes.js:13:25)
It seams that it's failing on this line 它接近它在这条线上失败了
router.use(multer({ dest: './public/uploads/'}));
Though it works locally completely fine? 虽然它在当地工作完全没问题? Has me a bit stumped. 让我有点难过。 Wonder if its related to multer? 不知道它是否与缪尔有关? I have the node module installed. 我安装了节点模块。 Thoughts? 思考?
Recent versions of multer
changed the API. 最新版本的multer
改变了API。 If you look at the examples , you will see you now have to do something like: 如果你看一下这些例子 ,你会发现你现在必须做的事情如下:
var upload = multer({ dest: './public/uploads/'});
// ...
router.use(upload.single('foofield'));
Or upload.array()
or upload.fields()
. 或者upload.array()
或upload.fields()
。
声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.