admin管理员组

文章数量:1406064

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().

本文标签: javascriptPossible issue with multer Error Routeruse() requires callbackStack Overflow