2

使用 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有关?我已经安装了节点模块。想法?

4

1 回答 1

8

最新版本multer更改了 API。如果您查看示例,您会发现您现在必须执行以下操作:

var upload = multer({ dest: './public/uploads/'});

// ...

router.use(upload.single('foofield'));

upload.array()upload.fields()

于 2015-07-24T15:14:12.513 回答