如何修复Node.js中的Heroku Web部署错误(例如:H10)?

时间:2019-04-24 06:42:25

标签: javascript node.js heroku web-deployment webdeploy

问题摘要

  • 访问从Heroku部署的网站时出现H10错误。
  • 它在本地服务器上运行没有任何问题。
  • 更新NPM然后部署到Heroku之后,发生了错误。
  • 详细的NPM错误显示“找不到模块”和“启动脚本失败”

我应该如何解决此问题?

以前的方法

我已经搜索了此问题的解决方案,并检查了端口设置,procfile,package.json和.gitignore,但是仍然出现错误。

代码示例

我在app.js中的端口设置

state

package.json

$ ./bin/fgetssscanf dat/field15pipes.txt
01|8a|0b|6c|82|1d|33|5e|4f|7.|0.|4g|3h|7.|5.  =>  name: 8a, state: 6c
01|9a|5b|0c|42|1d|93|3e|9f|8.|0.|5g|4h|6.|5.  =>  name: 9a, state: 0c
01|4a|5b|7c|22|0d|23|1e|1f|7.|2.|1g|5h|7.|7.  =>  name: 4a, state: 7c
01|8a|2b|5c|72|1d|53|6e|2f|1.|1.|8g|0h|7.|6.  =>  name: 8a, state: 5c
11|4a|6b|5c|92|2d|73|0e|6f|4.|2.|2g|7h|2.|4.  =>  name: 4a, state: 5c
01|2a|6b|0c|02|1d|83|0e|2f|5.|2.|9g|4h|3.|8.  =>  name: 2a, state: 0c
31|1a|0b|0c|72|2d|13|3e|3f|9.|0.|2g|5h|6.|9.  =>  name: 1a, state: 0c
01|8a|3b|7c|92|1d|93|3e|9f|6.|1.|4g|4h|8.|3.  =>  name: 8a, state: 7c
11|1a|4b|7c|42|2d|73|0e|5f|7.|0.|0g|5h|1.|7.  =>  name: 1a, state: 7c
21|8a|6b|9c|22|2d|23|2e|1f|9.|0.|1g|6h|6.|8.  =>  name: 8a, state: 9c

.gitignore

> let port = process.env.PORT; if (port == null || port == "") {   port
> = 3000; }
> 
> app.listen(port,function() {   console.log("Server started on port
> 3000"); });

Procfile

> {   "name": "todolist-v1",   "version": "1.0.0",   "description": "", 
> "main": "app.js",   "scripts": {
>     "test": "echo \"Error: no test specified\" && exit 1",
>     "start": "node app.js"
> 
>   },   "author": "",   "license": "ISC",   "engines": {
>     "node": "10.14.2"
> 
>   },   "dependencies": {
>     "async": "^2.6.2",
>     "body-parser": "^1.18.3",
>     "date-and-time": "^0.6.3",
>     "ejs": "^2.6.1",
>     "express": "^4.16.4",
>     "jsqr": "^1.2.0",
>     "lodash": "^4.17.11",
>     "moment": "^2.24.0",
>     "mongoose": "^5.5.2"   } }

heroku错误

/node_modules
npm-debug.log
.DS_Store
/*.env

NPM错误

web: node app.js

0 个答案:

没有答案