节点js npm启动错误

node js npm start error

我是按照本教程开始学习 nodejs MEAN STACK

现在我在模块 3,当我启动 npm start 命令时。我收到以下错误。 这是错误:pastebin

您一定忘记了在 package.json 文件中定义启动脚本。应该是这样的。

"scripts": {
"start": "node ./bin/www"
},

文章定义的很好。看看package.json

收到的第一个错误是在运行脚本但脚本失败时抛出的一般 npm 错误。在这种情况下,./bin/www 脚本失败,如第一个 stack trace:

的第 29 至 31 行所示
> 17 error module-3@0.0.0 start: `node ./bin/www`
> 17 error Exit status 1
> 18 error Failed at the module-3@0.0.0 start script 'node ./bin/www'.

运行 直接从命令行使用 > node ./bin/www 确认脚本在执行时抛出错误。

Error: Route.post() requires callback functions but got a [object Object]

这似乎是 post 方法正在接收一些非 function 参数。我会寻找引用此项目代码的堆栈跟踪行,因为 route.js 是来自 Express 框架的一些完善的代码。


at module.exports (C:\Users\prk\Documents\Learn node.js\MEAN MVA\module-3\routes\authenticate.js:16:12)

根据 Express documentationRouter.post() 方法的第一个参数以外的所有参数都必须是函数。似乎这一行发生的任何事情都会将非 function 值传递给 Router.post。如果它密切关注 git 存储库,看起来 passport.authenticate() 正在返回一个对象而不是函数。您需要执行更多调试才能找到答案。