我有一个sails js app我试图在heroku服务器上启动。据我所知,heroku应用程序默认安装ruby而不是节点。
我有一个bower.json文件,一个package.json文件和一个Procfile。
ERROR:
Starting process with command `node app.js`
bash: node: command not found
Procfile:
web: node app.js
的package.json:
{
"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,如果启动服务器就好了。 npm start和npm install工作正常。 node app.js启动应用就好了。
我发现当我通过:heroku run bash
我得到一个命令行,我可以运行它们:
~ $ which ruby
/app/bin/ruby
~ $ npm install
bash: npm: command not found
~ $ bower install
bash: bower: command not found
~ $ which git
/usr/bin/git
我做错了什么?!谢谢!
答案 0 :(得分:7)
好的,我找到了答案。每次我推新代码时都会说:
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
这是为了做到这一点:
$ heroku config:add BUILDPACK_URL=https://github.com/heroku/heroku-buildpack-nodejs
$ git commit -am "empty" --allow-empty
$ git push heroku master