gpt4 book ai didi

node.js - Heroku 不会运行 Node 。

转载 作者:搜寻专家 更新时间:2023-11-01 00:12:55 24 4
gpt4 key购买 nike

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

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

错误:

Starting process with command `node app.js`
bash: node: command not found

简介:

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 时: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

我做错了什么?!谢谢!

最佳答案

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

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 有一个默认顺序,它检测安装的服务器类型。在这种情况下,它是 ruby 。

我在这里找到了答案: 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

关于node.js - Heroku 不会运行 Node 。,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/30157336/

24 4 0
Copyright 2021 - 2024 cfsdn All Rights Reserved 蜀ICP备2022000587号
广告合作:1813099741@qq.com 6ren.com