当部署到 Heroku 时,meanjs 0.4.0 不工作

meanjs 0.4.0 not working when deployed to Heroku

我刚刚在本地主机上尝试了 meanjs 0.4.0 并且运行良好,但是当我部署到 heroku link to app 并尝试 "Sign up" 选项时,我在导航器控制台中得到了这个:

POST https://meanjsapptest.herokuapp.com/api/auth/signup 503 (Service Unavailable)

当我在 CLI 中编写命令和 heroku 日志时,我得到:

2017-06-06T04:15:35.152983+00:00 app[web.1]: (node:16) DeprecationWarning: Mongoose: mpromise (mongoose's default promise library) is deprecated, plug in your own promise library instead: http://mongoosejs.com/docs/promises.html
2017-06-06T04:15:35.153005+00:00 app[web.1]: crypto.js:635
2017-06-06T04:15:35.153006+00:00 app[web.1]: throw new TypeError(
2017-06-06T04:15:35.153006+00:00 app[web.1]: ^
2017-06-06T04:15:35.153007+00:00 app[web.1]:
2017-06-06T04:15:35.153008+00:00 app[web.1]: TypeError: The "digest" argument is required and must not be undefined
2017-06-06T04:15:35.153009+00:00 app[web.1]: at pbkdf2 (crypto.js:635:11)
2017-06-06T04:15:35.153010+00:00 app[web.1]: at Object.exports.pbkdf2Sync (crypto.js:628:10)
2017-06-06T04:15:35.153012+00:00 app[web.1]: at model. (/app/modules/users/server/models/user.server.model.js:112:26)
2017-06-06T04:15:35.153011+00:00 app[web.1]: at model.UserSchema.methods.hashPassword (/app/modules/users/server/models/user.server.model.js:123:19)
2017-06-06T04:15:35.153013+00:00 app[web.1]: at _next (/app/node_modules/hooks-fixed/hooks.js:62:30)
2017-06-06T04:15:35.153013+00:00 app[web.1]: at fnWrapper (/app/node_modules/hooks-fixed/hooks.js:186:8)
2017-06-06T04:15:35.153014+00:00 app[web.1]: at model. (/app/node_modules/mongoose/lib/plugins/saveSubdocs.js:20:7)
2017-06-06T04:15:35.153014+00:00 app[web.1]: at _next (/app/node_modules/hooks-fixed/hooks.js:62:30)
2017-06-06T04:15:35.153015+00:00 app[web.1]: at fnWrapper (/app/node_modules/hooks-fixed/hooks.js:186:8)
2017-06-06T04:15:35.153015+00:00 app[web.1]: at /app/node_modules/mongoose/lib/plugins/validateBeforeSave.js:33:13
2017-06-06T04:15:35.153016+00:00 app[web.1]: at /app/node_modules/kareem/index.js:131:16
2017-06-06T04:15:35.153016+00:00 app[web.1]: at _combinedTickCallback (internal/process/next_tick.js:95:7)
2017-06-06T04:15:35.153017+00:00 app[web.1]: at process._tickCallback (internal/process/next_tick.js:161:9)
2017-06-06T04:15:35.167579+00:00 app[web.1]: error: Forever detected script exited with code: 1
2017-06-06T04:15:35.173500+00:00 app[web.1]: error: Script restart attempt #1
2017-06-06T04:15:35.292903+00:00 app[web.1]:
2017-06-06T04:15:35.294191+00:00 app[web.1]:
2017-06-06T04:15:35.310954+00:00 app[web.1]: + Error: Certificate file or key file is missing, falling back to non-SSL mode
2017-06-06T04:15:35.311037+00:00 app[web.1]: To create them, simply run the following from your shell: sh ./scripts/generate-ssl-certs.sh
2017-06-06T04:15:35.311039+00:00 app[web.1]:
2017-06-06T04:15:35.916892+00:00 app[web.1]: Db.prototype.authenticate method will no longer be available in the next major release 3.x as MongoDB 3.6 will only allow auth against users in the admin db and will no longer allow multiple credentials on a socket. Please authenticate using MongoClient.connect with auth credentials.

我不知道现在该怎么办,因为 Heroku 支持人员告诉我错误出在我的代码中,但我没有更改那里的任何内容!

CLI screenshot

刚遇到这个问题。我们能够通过在 package.json > engines.

中强制执行我们的首选节点版本来修复它

我们之前在

"node": ">=0.10.0"

我们改成了

"node": "6.6.0"

然后将其推送到 Heroku,问题就解决了。

不完全确定问题出在哪里,但我们发现这个 link 让我们相信节点版本是问题所在:

https://github.com/nodejs/node/wiki/Breaking-changes-between-v4-LTS-and-v6-LTS#crypto