【问题标题】:Heroku | Node.js: No cedar-supported app detected赫罗库 | Node.js:未检测到雪松支持的应用程序
【发布时间】:2016-01-27 09:55:05
【问题描述】:

我要做什么

我正在尝试将这个简单的应用程序推送到 Heroku:

var express = require("express");
var app = express();

app.set('port', (process.env.PORT || 5000));

app.get ("/", function(req, res) {
        res.send('Hello World')
});

app.listen(app.get('port'));

来自包含这些文件的 git 根目录:

drwxr-xr-x@  9 test  staff   306 27 Okt 20:41 .
drwx------@ 16 test  staff   544 27 Okt 20:28 ..
-rw-r--r--@  1 test  staff  6148 22 Okt 08:57 .DS_Store
drwxr-xr-x@ 11 test  staff   374 27 Okt 20:28 .git
-rw-r--r--@  1 test  staff    18 27 Okt 16:05 Procfile
-rw-r--r--@  1 test  staff   196 27 Okt 15:46 index.js
drwxr-xr-x@  3 test  staff   102 27 Okt 20:28 node_modules
-rw-r--r--@  1 test  staff   323 27 Okt 20:41 package.json
-rw-r--r--@  1 test  staff   323 27 Okt 20:31 package.json~

package.json 有这个内容的地方:

{
  "name": "podio_script",
  "version": "1.0.0",
  "description": "test",
  "main": "index.js",
  "scripts": {
    "start": "node index.js"
  },
  "dependencies": {
   "express": "4.13.3"
  },
  "engines": {
   "node": "0.12.7"
  },
  "author": "James Dean",
  "license": "MIT"
}

Procfile 有这样的内容:

web: node index.js

我的问题是什么

当我运行 git push heroku master 时,我收到以下错误消息:

!推送被拒绝,没有检测到支持 Cedar 的应用程序远程:提示: 当 Heroku 无法检测到 buildpack 远程时会发生这种情况: 自动用于此应用程序。远程:见 https://devcenter.heroku.com/articles/buildpacks

我能够找到的资源告诉我,此消息是由缺少 package.json 文件引起的。但在我的情况下,文件就在那里。

我做错了什么? TIA

【问题讨论】:

  • 嘿,我刚试过这个,我没有看到任何问题,我创建了一个默认的 express 应用程序,放置了你的 index.js(而不是 app.js)并用你的替换了 package.json,推送到heroku 和 voilla ,没有错误 morning-chamber-5036.herokuapp.com 唯一的问题是,我没有 Procfile ... vl 稍后尝试
  • 它也适用于我——你确定你的 package.json 文件包含在 Git 中吗? EG:确保它确实被提交并推送到 Heroku,否则你会得到上述错误。
  • 谢谢你,aishwatsingh 和 rdegges。这确实是一个基本的初学者错误:未提交的文件。它现在正在工作。感谢您的宝贵时间。

标签: node.js heroku


【解决方案1】:

在推送到 Heroku 之前,必须执行以下 git 步骤:

git init // create repository
git add [files] // add all relevant files to the repository
git commit // commit the new files

【讨论】:

    猜你喜欢
    • 1970-01-01
    • 1970-01-01
    • 1970-01-01
    • 1970-01-01
    • 1970-01-01
    • 1970-01-01
    • 2015-09-28
    • 2014-01-22
    • 2013-01-11
    相关资源
    最近更新 更多