尝试在 render.com 上部署网站不起作用

问题描述 投票:0回答:1

我正在尝试部署一个用express、ejs 和 mongodb 制作的应用程序。 render 说我的服务已上线,但当我加载页面时,我不断收到“此页面无法正常工作 HTTP ERROR 502”。

//is thus a possible reason => Aug 3 05:37:25 PM  ==> No open HTTP ports detected.
//Aug 3 05:37:26 PM  ==> https://render.com/docs/web-services#host-and-port-configuration
Aug 3 05:37:46 PM  ==> Using Node version 14.17.0 (default)
Aug 3 05:37:46 PM  ==> Docs on specifying a Node version: https://render.com/docs/node-version
Aug 3 05:37:46 PM  ==> Starting service with 'npm start'
Aug 3 05:37:47 PM  
Aug 3 05:37:47 PM  > [email protected] start /opt/render/project/src
Aug 3 05:37:47 PM  > node server.js
Aug 3 05:37:47 PM  
Aug 3 05:37:51 PM  Connected to MongoDB
Aug 3 05:37:51 PM  Server is running on http://localhost:3000
Aug 3 05:37:56 PM  Your service is live 🎉
Aug 3 07:07:09 PM  ==> Using Node version 14.17.0 (default)
Aug 3 07:07:09 PM  ==> Docs on specifying a Node version: https://render.com/docs/node-version
Aug 3 07:07:09 PM  ==> Starting service with 'npm start'
Aug 3 07:07:10 PM  
Aug 3 07:07:10 PM  > [email protected] start /opt/render/project/src
Aug 3 07:07:10 PM  > node server.js
Aug 3 07:07:10 PM  
Aug 3 07:07:15 PM  Connected to MongoDB
Aug 3 07:07:15 PM  Server is running on http://localhost:3000```

any ideas why this might be happening

mongodb express ejs web-hosting render.com
1个回答
0
投票

尝试在 render.com 仪表板的设置页面中将启动命令更改为

npm run start

根据给出的信息很难判断,但问题可能是你的启动命令。我总是需要使用

npm run start
但你正在使用
npm start
。有些教程似乎犯了错误(然后稍后更改)。如果您遵循其中之一,他们可能会误导您。

npm run <script-name>
从您的
package.json
文件调用脚本。如果你省略了“run”关键字,npm 就不知道要做什么。另外,我的启动命令如下所示,你的应该类似:

"scripts": {
  "start": "node build/app.js",
  "another-script": "you get the idea"
},
© www.soinside.com 2019 - 2024. All rights reserved.