简体   繁体   English

multer可能出现的问题? 错误:Router.use()需要回调

[英]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.

相关问题 Express Router.use需要回调函数错误 - Express Router.use requires callback function error router.use()需要中间件功能错误 - router.use() requires middleware function error Express-试图模仿控制器。 得到了Router.use()需要回调函数,但是出现了[object String]错误 - Express - Trying to imitate controllers. Got Router.use() requires callback functions but got a [object String] error 创建Router.use()的路由时出错,需要中间件功能 - Creating route got error of Router.use() requires middleware function Router.use需要中间件功能吗? - Router.use requires middleware function? 如何解决“ Router.use()需要中间件功能,但在Function.use获得对象”错误 - How to solve “Router.use() requires a middleware function but got a Object at Function.use” error Express 路由器:Router.use() 需要中间件 function 但得到了 Object - Express router : Router.use() requires a middleware function but got a Object 为什么 npm run 会导致错误:“Router.use() requires a middleware function but a &#39; + gettype(fn)”? - Why does npm run result in the error: “Router.use() requires a middleware function but a ' + gettype(fn)”? 我运行此代码,但显示 router.use() 需要中间件功能,但出现 &#39; + gettype(fn) 这个错误 - i run this code but showing router.use() requires a middleware function but got a ' + gettype(fn) this error 表达错误:抛出新的TypeError(&#39;Router.use()需要中间件功能,但得到了&#39;+ gettype(fn)); - Express error: throw new TypeError('Router.use() requires middleware function but got a ' + gettype(fn));
 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM