【问题标题】:NodeJS app builds with Heroku, but it shows application errorNodeJS 应用程序使用 Heroku 构建,但显示应用程序错误
【发布时间】:2017-05-12 07:43:40
【问题描述】:

我正在设置一个 NodeJS Heroku 应用程序。我只想启动并运行一个空的应用程序。

我的目录包括一个 package.json 和一个 app.js 文件。

Heroku 应用程序构建时没有错误,但我只是在 URL (https://nameless-wave-98692.herokuapp.com/) 上看到“应用程序错误”页面。

据我所知,日志中的一切看起来都不错:

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

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

       Downloading and installing node 6.9.2...
       Using default npm version: 3.10.9
-----> Restoring cache
       Loading 2 from cacheDirectories (default):
       - node_modules
       - bower_components (not cached - skipping)
-----> Building dependencies
       Installing node modules (package.json)
-----> Caching build
       Clearing previous node cache
       Saving 2 cacheDirectories (default):
       - node_modules
       - bower_components (nothing to cache)
-----> Build succeeded!
       └── (empty)
         !     This app may not specify any way to start a node process
       https://devcenter.heroku.com/articles/nodejs-support#default-web-process-type
-----> Discovering process types
       Procfile declares types     -> (none)
       Default types for buildpack -> web
-----> Compressing...
       Done: 13.4M
-----> Launching...
       Released v4
       https://nameless-wave-98692.herokuapp.com/ deployed to Heroku

你有什么问题吗?我做错了吗?

【问题讨论】:

标签: javascript node.js heroku deployment


【解决方案1】:

也许你需要文件Procfile

web: node app.js

【讨论】:

  • 谢谢大卫,我添加了 procfile。这是朝着正确方向迈出的一步,但我仍然收到错误...
  • 是的,是的。它看起来像这样:nameless-wave-98692.herokuapp.com。在控制台或其他地方看不到错误:/
  • 构建完成后 Heroku 给我的日志:pastebin.com/VwPjTV23 感谢您抽出时间提供帮助 :-)
  • 非常感谢大卫,我现在开始工作了!我现在只是将我的所有代码从 app.js 移动到 server.js 吗?并删除 app.js
  • (我制作了一个 server.js 文件,如教程中所述。)
【解决方案2】:

【讨论】:

  • 谢谢吉姆,非常有用的链接。我添加了procfile。这是朝着正确方向迈出的一步,但我仍然收到错误...
猜你喜欢
  • 2018-04-07
  • 2021-08-23
  • 1970-01-01
  • 1970-01-01
  • 2021-04-08
  • 1970-01-01
  • 2019-07-27
  • 2021-08-28
  • 1970-01-01
相关资源
最近更新 更多