Possible issue with multer? Error: Router.use() requires callback
Possible issue with multer? Error: Router.use() requires callback
使用 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)
它似乎在这条线上失败了
router.use(multer({ dest: './public/uploads/'}));
尽管它在本地完全正常工作?让我有点难过。
想知道它是否与multer有关?我安装了节点模块。
想法?
multer
的最新版本更改了 API。如果您查看 examples,您会发现您现在必须执行以下操作:
var upload = multer({ dest: './public/uploads/'});
// ...
router.use(upload.single('foofield'));
或upload.array()
或upload.fields()
。
使用 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)
它似乎在这条线上失败了
router.use(multer({ dest: './public/uploads/'}));
尽管它在本地完全正常工作?让我有点难过。 想知道它是否与multer有关?我安装了节点模块。 想法?
multer
的最新版本更改了 API。如果您查看 examples,您会发现您现在必须执行以下操作:
var upload = multer({ dest: './public/uploads/'});
// ...
router.use(upload.single('foofield'));
或upload.array()
或upload.fields()
。