简体   繁体   English

使用Heroku进行节点部署时出现“应用程序错误”

[英]“Application Error” when deploying with Heroku for node

I managed to finally make a running client-server easy app in local (after weeks of trying) and... I tried to give Heroku a try, so my last server was so confusing and frustrating. 我终于设法在本地制作了一个易于运行的客户端-服务器简易应用程序(经过数周的尝试),并且...我尝试尝试一下Heroku,所以我的最后一台服务器是如此令人困惑和沮丧。 It seemed it was working but... after an "okay" deploy, the web shows "An error occurred in the application and your page could not be served. If you are the application owner, check your logs for details.". 看来它正在运行,但是...“正常”部署后,网络显示“应用程序中发生错误,无法提供您的页面。如果您是应用程序所有者,请检查日志以了解详细信息。”。

I found things like allowing to run in process.env.PORT and not only 8080 port, fixed it, but still the same mistake, though still working in local. 我发现诸如允许在process.env.PORT上运行,并且不仅修复了8080端口,还修复了相同的错误,尽管仍然可以在本地运行。 Any advice? 有什么建议吗?

The log of the deploy... 部署日志...

-----> 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

In your JSON file, have you remebered to included your "start" value which is the command that you want the server to do on startup. 在JSON文件中,您是否建议您包含“开始”值,这是您希望服务器在启动时执行的命令。 For node the start of your JSON should look like this: 对于节点,JSON的开始应如下所示:

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

Hope this helps :) 希望这可以帮助 :)

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM