您好,这是我的package.json文件。但是Heroku告诉我应用程序错误应用程序中发生了一个错误,无法提供您的页面
您好,这是我的json文件格式,当我运行node index.js时,它在本地机器上运行良好您好,这是我的package.json文件。但是Heroku告诉我应用程序错误应用程序中发生了一个错误,无法提供您的页面,heroku,deployment,Heroku,Deployment,您好,这是我的json文件格式,当我运行node index.js时,它在本地机器上运行良好 { "name": "a-simple-nodejs-website", "version": "1.0.0", "description": "", "main": "index.js", "scripts": { "test": "node index.js" }, "author": "Theodore Kelechukwu Onyejiaku", "lic
{
"name": "a-simple-nodejs-website",
"version": "1.0.0",
"description": "",
"main": "index.js",
"scripts": {
"test": "node index.js"
},
"author": "Theodore Kelechukwu Onyejiaku",
"license": "ISC"
}
但是Heroku告诉我:
应用程序错误
应用程序中出现错误,无法提供您的页面…您需要在package.json中提到引擎,如下所示
{
"name": "a-simple-nodejs-website",
"version": "1.0.0",
"description": "",
"main": "index.js",
"engines": {
"node": "10.x"
},
"scripts": {
"test": "node index.js"
},
"author": "Theodore Kelechukwu Onyejiaku",
"license": "ISC"
}
检查index.js中的应用程序端口。如果设置为静态端口,请按如下所示进行更改:
const PORT = process.env.PORT || 5000
在服务器侦听方法中传递此端口。json文件中没有开始脚本,因此添加=>“开始”:“node index.js”。 下面是傻瓜代码示例
{
"name": "a-simple-nodejs-website",
"version": "1.0.0",
"description": "",
"main": "index.js",
"scripts": {
"test": "node index.js",
"start": "node index.js"
},
"author": "Theodore Kelechukwu Onyejiaku",
"license": "ISC"
}
谢谢,是的,我这样做了。我已经将端口设置为process.env.PORT | | 5000。我已经解决了这个问题。请查看下面我的评论。如果您认为此答案有帮助,请选择“接受”。