部署后 Nodejs 不会在 heroku 上启动
Nodejs won't start on heroku after deploy
我对 NodeJs 有点菜鸟,但我尝试发布一个 运行 在本地连接到 heroku.but 的应用程序,它在启动后一直抛出 H10 错误。
at=error code=H10 desc="App crashed" method=GET path="/" host=secure-shelf-30086.herokuapp.com request_id=275885c2-48f1-410d-8651-e6aa4311f65b fwd="81.49.127.42" dyno= connect= service= status=503 bytes= protocol=https
at=error code=H10 desc="App crashed" method=GET path="/favicon.ico" host=secure-shelf-30086.herokuapp.com request_id=f29afde7-6e30-4b7f-b22f-5b01599b6cdf fwd="81.49.127.42" dyno= connect= service= status=503 bytes= protocol=https
这是我的package.json
{
"name": "App name",
"version": "0.0.1",
"description": "App desc",
"main": "app.js",
"engines": {
"node": "v14.0.0",
"npm": "6.x"
},
"scripts": {
"start": "node app.js"
},
"repository": {
"type": "git",
"url": "https://github.com/nickname/xxx-xxx.git"
},
"author": "nickname",
"license": "ISC",
"bugs": {
"url": "https://github.com/nickname/xxx-xxx/issues"
},
"homepage": "https://github.com/nickname/xxx--xxx#readme",
"dependencies": {
"ent": "^2.2.0",
"express": "^4.17.1",
"simple-ssh": "^1.0.0",
"socket.io": "^2.3.0"
}
}
我的app.js
文件的开头
var app = require('express')(),
server = require('http').createServer(app),
io = require('socket.io').listen(server),
ent = require('ent');
var SSH = require('simple-ssh');
由于我对其他帖子的研究,我在我的存储库中添加了一个 Procfile
条目,例如:
web:npm start
我的 heroku 应用程序上有我的配置
NODE_ENV: production npm start
NODE_MODULES_CACHE: false
会不会是因为缺少 favicon 文件???
我很想在 heroku 上找到 运行 这个应用程序的方法(我 运行 在免费计划中使用它)
谢谢
确保您在正常端口号旁边使用 (process.env.PORT)
const PORT = process.env.PORT || 3000;
app.listen(PORT, () => {
console.log(`Our app is running on port ${ PORT }`);
});
我对 NodeJs 有点菜鸟,但我尝试发布一个 运行 在本地连接到 heroku.but 的应用程序,它在启动后一直抛出 H10 错误。
at=error code=H10 desc="App crashed" method=GET path="/" host=secure-shelf-30086.herokuapp.com request_id=275885c2-48f1-410d-8651-e6aa4311f65b fwd="81.49.127.42" dyno= connect= service= status=503 bytes= protocol=https
at=error code=H10 desc="App crashed" method=GET path="/favicon.ico" host=secure-shelf-30086.herokuapp.com request_id=f29afde7-6e30-4b7f-b22f-5b01599b6cdf fwd="81.49.127.42" dyno= connect= service= status=503 bytes= protocol=https
这是我的package.json
{
"name": "App name",
"version": "0.0.1",
"description": "App desc",
"main": "app.js",
"engines": {
"node": "v14.0.0",
"npm": "6.x"
},
"scripts": {
"start": "node app.js"
},
"repository": {
"type": "git",
"url": "https://github.com/nickname/xxx-xxx.git"
},
"author": "nickname",
"license": "ISC",
"bugs": {
"url": "https://github.com/nickname/xxx-xxx/issues"
},
"homepage": "https://github.com/nickname/xxx--xxx#readme",
"dependencies": {
"ent": "^2.2.0",
"express": "^4.17.1",
"simple-ssh": "^1.0.0",
"socket.io": "^2.3.0"
}
}
我的app.js
文件的开头
var app = require('express')(),
server = require('http').createServer(app),
io = require('socket.io').listen(server),
ent = require('ent');
var SSH = require('simple-ssh');
由于我对其他帖子的研究,我在我的存储库中添加了一个 Procfile
条目,例如:
web:npm start
我的 heroku 应用程序上有我的配置
NODE_ENV: production npm start
NODE_MODULES_CACHE: false
会不会是因为缺少 favicon 文件???
我很想在 heroku 上找到 运行 这个应用程序的方法(我 运行 在免费计划中使用它)
谢谢
确保您在正常端口号旁边使用 (process.env.PORT)
const PORT = process.env.PORT || 3000;
app.listen(PORT, () => {
console.log(`Our app is running on port ${ PORT }`);
});