node.js - 为什么 Heroku 无法检测到 Node.js buildpack?

标签 node.js git heroku git-clone buildpack

我 git 克隆了一个 Node.js 应用程序(在 package.json 中指定的版本是 4.1.2,而我的本地机器的版本是 6.2。 2) 并尝试在 Heroku 上进行 git push。但是它构建失败并给出了这个错误:

Failed to detect set buildpack https://codon-buildpacks.s3.amazonaws.com/buildpacks/heroku/nodejs.tgz

现在我将 buildpack 设置为 heroku/nodejs 并收到以下消息:

Buildpack set. Next release on lit-badlands-92088 will use heroku/nodejs.
Run git push heroku master to create a new release using this buildpack.

现在当我运行 git push heroku master 时,我再次被告知:

remote: -----> Failed to detect set buildpack
        https://codon-buildpacks.s3.amazonaws.com/buildpacks/heroku/nodejs.tgz  

remote: More info: 
https://devcenter.heroku.com/articles/buildpacks#detection-failure  

remote:  
remote:  !     Push failed  
remote: Verifying deploy...  
remote:  
remote: !       Push rejected to lit-badlands-92088.

即使我设置了 Node.js buildpack 也未检测到的可能原因是什么?

最佳答案

这意味着 package.json 文件没有检入到您的 git 项目的根目录中,因此 Heroku 检测到它不是 Node.js 应用程序。你可以在本地看到这个:

git show master:package.json

要修复它,您需要确保项目的根目录中有一个 package.json(其中还有一个 .git 目录),并将其添加到 git:

git add package.json
git commit -m 'track package.json'

可以改进措辞(“未能检测到 set buildpack”)。它可能应该说“未能检测到 Node.js 应用程序”。运行 buildpack 的“检测”脚本 (https://github.com/heroku/heroku-buildpack-nodejs/blob/master/bin/detect) 时,它会查找 package.json 文件以验证是否有 Node 应用可供构建。

关于node.js - 为什么 Heroku 无法检测到 Node.js buildpack?,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/38658038/

相关文章:

node.js - Node-acl 方法 "isAllowed"总是意外返回 false

javascript - 西农 stub 给出 'is not a function' 错误

git - 从git repo Docker化go应用程序

node.js - Express 服务的 Vuejs 前端和 Node 安全实践中的后端 API

ruby-on-rails - 在 Heroku 上的 Rails 应用程序之间共享用户数据和登录信息

javascript - 序列化 : How to query model by 1:n association, 但在单个查询中包含所有关联对象 (PostgreSQL)

node.js - 如何使用 AVA 和 Mongoose 运行并行测试

Git reflog 一个特定的分支?

git diff 只有我的改变

javascript - Heroku 上的 Discord 机器人抛出错误 : agent ? ?= new https.Agent