【问题标题】:unable to push node.js app on heroku无法在 heroku 上推送 node.js 应用程序
【发布时间】:2017-01-31 07:52:30
【问题描述】:

我尝试在 heroku 上推送我的 node.js 应用程序,但是。无法检测到此应用的默认语言。我什至尝试过 heroku buildpacks:set heroku/nodejs。但是还是推不开。

 Counting objects: 31, done.
    Delta compression using up to 4 threads.
    Compressing objects: 100% (24/24), done.
    Writing objects: 100% (31/31), 5.37 KiB | 0 bytes/s, done.
    Total 31 (delta 3), reused 0 (delta 0)
    remote: Compressing source files... done.
    remote: Building source:
    remote: 
    remote:  !     No default language could be detected for this app.
    remote:             HINT: This occurs when Heroku cannot detect the buildpack to use for this application automatically.
    remote:             See https://devcenter.heroku.com/articles/buildpacks
    remote: 
    remote:  !     Push failed
    remote: Verifying deploy...
    remote: 
    remote: !   Push rejected to radiant-cliffs-91678.
    remote: 
    To https://git.heroku.com/radiant-cliffs-91678.git
     ! [remote rejected] master -> master (pre-receive hook declined)
    error: failed to push some refs to 'https://git.heroku.com/radiant-cliffs-91678.git'

【问题讨论】:

    标签: javascript node.js git heroku


    【解决方案1】:

    根据您的日志,Heroku 似乎无法检测到您应用的语言。

    对于 Node.js,您需要在项目的根目录中创建一个 package.json 文件(使用 npm init 之类的东西),或者您可以在项目的根目录中创建一个 Procfile 来指定您的语言:

    web: node index.js
    

    【讨论】:

    • 我有 package.json 和 Procfile
    • 这两个文件都在你项目的根目录下吗?
    • 另外,您是否将项目的主分支推送到提交这些文件的位置?
    • 我有 2 个 angular 和 backend 文件夹,我的 package.json 和 procfile 都在 backend 文件夹中
    • @AnkitKumar 啊,这就是为什么。 Heroku 只在最顶层的文件夹中查找。您需要在根目录中拥有 Procfile。然后在 Procfile 中将其指向 web: node backend/index.js 或任何起始文件的相对路径。
    【解决方案2】:

    转到命令行并运行以下命令:

    heroku buildpacks:set -a app_name heroku/node
    

    【讨论】:

      猜你喜欢
      • 1970-01-01
      • 1970-01-01
      • 2014-08-05
      • 2023-03-15
      • 2016-02-25
      • 2020-09-24
      • 1970-01-01
      • 1970-01-01
      • 2016-01-10
      相关资源
      最近更新 更多