gpt4 book ai didi

javascript - 使用 Heroku for Node 进行部署时出现 "Application Error"

转载 作者:行者123 更新时间:2023-12-03 02:10:35 27 4
gpt4 key购买 nike

我终于成功地在本地创建了一个运行客户端-服务器的简单应用程序(经过几周的尝试)并且......我试图尝试 Heroku,所以我的最后一个服务器是如此令人困惑和令人沮丧。看起来它正在工作,但是......在“正常”部署之后,网络显示“应用程序中发生错误,无法提供您的页面。如果您是应用程序所有者,请检查日志以获取详细信息。”。

我发现允许在 process.env.PORT 中运行,而不仅仅是 8080 端口,修复了它,但仍然是同样的错误,尽管仍然在本地工作。有什么建议吗?

部署日志...

-----> Node.js app detected
-----> Creating runtime environment

NPM_CONFIG_LOGLEVEL=error
NODE_VERBOSE=false
NODE_ENV=production
NODE_MODULES_CACHE=true
-----> Installing binaries
engines.node (package.json): unspecified
engines.npm (package.json): unspecified (use default)

Resolving node version 8.x...
Downloading and installing node 8.11.1...
Using default npm version: 5.6.0
-----> Restoring cache
Loading 2 from cacheDirectories (default):
- node_modules
- bower_components (not cached - skipping)
-----> Building dependencies
Installing node modules (package.json + package-lock)
up to date in 3.888s
-----> Caching build
Clearing previous node cache
Saving 2 cacheDirectories (default):
- node_modules
- bower_components (nothing to cache)
-----> Pruning devDependencies
Skipping because npm 5.6.0 sometimes fails when running 'npm prune' due to a known issue
https://github.com/npm/npm/issues/19356

You can silence this warning by updating to at least npm 5.7.1 in your package.json
https://devcenter.heroku.com/articles/nodejs-support#specifying-an-npm-version
-----> Build succeeded!
-----> Discovering process types
Procfile declares types -> (none)
Default types for buildpack -> web
-----> Compressing...
Done: 19.4M
-----> Launching...
Released v5
https://myweb.herokuapp.com/ deployed to Heroku

最佳答案

在您的 JSON 文件中,您是否记得包含“开始”值,这是您希望服务器在启动时执行的命令。对于 Node ,JSON 的开头应如下所示:

{
"name": "deploying",
"version": "1.0.0",
"description": "",
"main": "app.js",
"scripts": {
"test": "echo \"Error: no test specified\" && exit 1",
"start": "node app.js"

希望这有帮助:)

关于javascript - 使用 Heroku for Node 进行部署时出现 "Application Error",我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/49590203/

27 4 0
Copyright 2021 - 2024 cfsdn All Rights Reserved 蜀ICP备2022000587号
广告合作:1813099741@qq.com 6ren.com