javascript - Possible issue with multer? Error: Router.use() requires callback - Stack Overflow

Building a site with yeoman angular-fullstack works great locally, but when I deploy and use the distr

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.

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._pile (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 pletely fine? Has me a bit stumped. Wonder if its related to multer? I have the node module installed. Thoughts?

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.

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._pile (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 pletely fine? Has me a bit stumped. Wonder if its related to multer? I have the node module installed. Thoughts?

Share Improve this question asked Jul 24, 2015 at 15:00 JustinJustin 3,0393 gold badges28 silver badges47 bronze badges
Add a ment  | 

1 Answer 1

Reset to default 8

Recent versions of multer changed the 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().

发布者:admin,转转请注明出处:http://www.yc00.com/questions/1744965703a4603667.html

相关推荐

发表回复

评论列表(0条)

  • 暂无评论

联系我们

400-800-8888

在线咨询: QQ交谈

邮件:admin@example.com

工作时间:周一至周五,9:30-18:30,节假日休息

关注微信