首页
学习
活动
专区
圈层
工具
发布
社区首页 >问答首页 >Heroku不会运行node。

Heroku不会运行node。
EN

Stack Overflow用户
提问于 2015-05-11 06:33:28
回答 1查看 3.7K关注 0票数 2

我有一个sails js应用程序,我正在尝试在heroku服务器上启动。据我所知,heroku应用默认安装的是ruby而不是node。

我有一个bower.json文件,一个package.json文件和一个Procfile文件。

错误:

代码语言:javascript
复制
Starting process with command `node app.js`
bash: node: command not found

Procfile:

代码语言:javascript
复制
web: node app.js

Package.json:

代码语言:javascript
复制
{
  "name": "app",
  "private": true,
  "version": "0.0.1",
  "dependencies": {
    "node": "*",
    "sails": "~0.10.5",
    "sails-disk": "~0.10.0",
    "request": "^2.51.0",
    "node-fullbox-api": "*",
    "stripe": "*",
    "rc": "~0.5.0",
    "bower": "^1.3.9",
    "grunt": "^0.4.5",
    "grunt-banner": "^0.2.3",
    "grunt-bower": "^0.14.0",
    "grunt-bowercopy": "^1.1.0",
    "grunt-concurrent": "^0.5.0",
    "grunt-config-dir": "^0.3.2",
    "grunt-contrib-clean": "^0.5.0",
    "grunt-contrib-compass": "^0.8.0",
    "grunt-contrib-concat": "^0.4.0",
    "grunt-contrib-connect": "^0.8.0",
    "grunt-contrib-copy": "^0.5.0",
    "grunt-contrib-cssmin": "^0.10.0",
    "grunt-contrib-htmlmin": "^0.3.0",
    "grunt-contrib-imagemin": "^0.7.2",
    "grunt-contrib-jshint": "^0.10.0",
    "grunt-contrib-requirejs": "^0.4.4",
    "grunt-contrib-watch": "^0.6.1",
    "grunt-githooks": "^0.3.1",
    "grunt-jscs": "^0.6.2",
    "grunt-lodash": "^0.4.0",
    "grunt-modernizr": "^0.5.2",
    "grunt-newer": "^0.7.0",
    "grunt-scss-lint": "^0.3.3",
    "grunt-string-replace": "^1.0.0",
    "grunt-stripmq": "0.0.6",
    "grunt-svgmin": "^0.4.0",
    "jquery-builder": "^0.7.0",
    "jshint-stylish": "^0.4.0",
    "lodash": "^1.3.1",
    "lodash-cli": "^3.1.0",
    "rjs-build-analysis": "0.0.3",
    "time-grunt": "^0.3.2",
    "grunt-contrib-coffee": "~0.10.1",
    "grunt-contrib-jst": "~0.6.0",
    "grunt-contrib-less": "0.11.1",
    "grunt-contrib-uglify": "~0.4.0",
    "grunt-sails-linker": "~0.9.5",
    "grunt-sync": "~0.0.4",
    "include-all": "~0.1.3",
    "underscore": "^1.7.0"
  },
  "scripts": {
    "postinstall": "node npm-postinstall.js"
  },
  "main": "app.js",
  "scripts": {
      "start": "node app.js",
      "debug": "node debug app.js"
  },
  "devDependencies": {
    "mkdirp": "^0.5.0",
    "shortid": "^2.1.3",
    "node": "*"
  },
  "engines": {
      "node": "*",
      "npm":  "*",
      "ruby": "*"
  }
}

至于测试:我可以运行heroku local,如果启动服务器就可以了。npm start和npm install运行得很好。node app.js可以很好地启动应用程序。

我发现当我通过:heroku run bash连接到heroku时

我得到了一个命令行,我可以运行以下命令:

代码语言:javascript
复制
~ $ which ruby
/app/bin/ruby
~ $ npm install
bash: npm: command not found
~ $ bower install
bash: bower: command not found
~ $ which git
/usr/bin/git

我做错了什么?!谢谢!

EN

回答 1

Stack Overflow用户

发布于 2015-05-11 10:02:29

好了,我找到答案了。每次我推送新代码时,它都会说:

代码语言:javascript
复制
remote: -----> Warning: Multiple default buildpacks reported the ability to handle this app. The first buildpack in the list below will be used.
remote:        Detected buildpacks: Ruby, Node.js
remote:        See https://devcenter.heroku.com/articles/buildpacks#buildpack-detect-order

再加上它所说的node command not found,我能够追踪到heroku有一个默认的顺序,它会检测安装的服务器类型。在这种情况下,它是红宝石。

我在这里找到了答案:Heroku wrongly detecting my Node app as a Ruby app

也就是要这样做:

代码语言:javascript
复制
$ heroku config:add BUILDPACK_URL=https://github.com/heroku/heroku-buildpack-nodejs
$ git commit -am "empty" --allow-empty
$ git push heroku master
票数 8
EN
页面原文内容由Stack Overflow提供。腾讯云小微IT领域专用引擎提供翻译支持
原文链接:

https://stackoverflow.com/questions/30157336

复制
相关文章

相似问题

领券
问题归档专栏文章快讯文章归档关键词归档开发者手册归档开发者手册 Section 归档