如何配置heroku的lite-server端口? [英] How to configure lite-server port for heroku?
问题描述
我试图在Heroku上部署nodejs lite-server。我能够在本地运行服务器,但在部署时出现此错误失败:
错误R10(启动超时) - > ; Web进程无法在启动60秒内绑定到$ PORT
基本问题是我不确定如何让Heroku设置端口。他们动态地做到这一点(我只知道如何静态地做)。所以我需要设置一个环境变量,以便服务器可以设置正确的端口。如何使用lite-server执行此操作?
此问题已针对不同的服务器设置:
为Heroku配置http服务器端口
Heroku + node.js错误(Web进程无法在启动后的60秒内绑定到$ PORT)
为Heroku配置Express服务器端口
Heroku Node.js错误R10(引导超时) - > Web进程无法在启动后的60秒内绑定到$ PORT
所以我遇到了同样的问题。我最终添加了一个bs-config.js文件。
module.exports = {
port:process.env .PORT,
文件:['./**/*.{html,htm,css,js}'],
服务器:{
baseDir:./
}
};
显然Heroku每次启动时动态分配一个新端口。所以端口不能被硬编码。
如何在端口8080上的C9.io上为TypeScript运行Angular.JS 2?
I am trying to deploy nodejs lite-server on Heroku. I am able to run the server fine locally, but fails on deployment with this error:
Error R10 (Boot timeout) -> Web process failed to bind to $PORT within 60 seconds of launch
The basic problem is I am not sure how to allow Heroku to set the port. They do this dynamically (I only know how to do it statically). So I need to set an environmental variable so the server can set the correct port. How can I do this using lite-server?
This problem has been address for different server setups:
To configure http server port for Heroku
Heroku + node.js error (Web process failed to bind to $PORT within 60 seconds of launch)
To configure Express server port for Heroku
So I had the same issue. I ended up adding a bs-config.js file.
module.exports = {
port: process.env.PORT,
files: ['./**/*.{html,htm,css,js}'],
server:{
baseDir: "./"
}
};
Apparently Heroku dynamically assigns a new port each time it's started. So the port can't be hard coded.
How do I run Angular.JS 2 for TypeScript on C9.io on port 8080?
这篇关于如何配置heroku的lite-server端口?的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!