【问题标题】:How to deploy node js app with gruntfile to heroku如何将带有 gruntfile 的节点 js 应用程序部署到 heroku
【发布时间】:2015-11-06 08:29:17
【问题描述】:

我正在尝试使用 BUILDPACK_URL 将 node js 应用程序部署到 heroku。我已经搜索了我的问题的解决方案,但没有得到任何适合我的问题的答案。

这是我遵循的程序:

 heroku create myapp
 heroku config:add BUILDPACK_URL='https://github.com/stephanmelzer/heroku-buildpack-nodejs-grunt-compass.git'

然后我提交我的更改,然后:

git push heroku master

它在grunt 任务开始之前运行良好。我已经安装了compass gem 来与 grunt 一起工作。 当 heroku 尝试启动 grunt 任务时,出现以下错误:

`remote: -----> Installing Compass
 remote: WARNING:  You don't have /tmp/build_2f866d4293332f62a9a9aa576a411628/.gem/ruby/2.2.0/bin in your PATH,
 remote:gem executables will not run.

`

在那个警告之后,我收到一条消息说指南针安装成功

remote: Building native extensions.  This could take a while...
remote: Successfully installed ffi-1.9.10
remote: Successfully installed rb-inotify-0.9.5
remote: Successfully installed rb-fsevent-0.9.5
remote: Successfully installed chunky_png-1.3.4
remote: Successfully installed sass-3.4.16
remote: Successfully installed compass-import-once-1.0.5
remote: Successfully installed compass-core-1.0.3
remote:     Compass is charityware. If you love it, please donate on   our behalf at http://umdf.org/compass Thanks!
remote: Successfully installed compass-1.0.3
remote: 8 gems installed

然后在 heroku 尝试运行 `grunt' 之后。此时我收到以下错误:

remote: -----> Running grunt heroku:production task
remote: Running "env:src" (env) task
remote: 
remote: Running "clean:dist" (clean) task
remote: 
remote: Running "compass:dist" (compass) task
remote: Warning: You need to have Ruby and Compass installed and in  your system PATH for this task to work. More info:   https://github.com/gruntjs/grunt-contrib-compass Use --force to continue.
remote: 
remote: Aborted due to warnings.

我不知道为什么它没有找到 PATH for compass gem,它已经安装在我的本地机器上。

which compass
result:  /home/username/.rvm/gems/ruby-2.2.0-preview1/bin/compass

谁能告诉我如何克服这个问题并正确设置 gem 的 PATH 变量。

非常感谢。

【问题讨论】:

  • 试试heroku config:add BUILDPACK_URL=https://github.com/[account]/heroku-buildpack-multi.git,看看是否可行。 From here.
  • 我试过了,但没有运气。非常感谢您的回复。

标签: javascript ruby node.js heroku gruntjs


【解决方案1】:

我刚刚查看了 buildback 源代码,并在 bin/compile 中看到了两次,它指的是 ruby​​ 1.9.1。两次都设置环境变量。

也许heroku升级了node buildpack中的ruby版本?

我会 fork 存储库并将值更改为正在寻找的 2.2.0 路径值。

您只需更改 buildpack 中的路径,或按照评论中的说明进行操作。

【讨论】:

  • 谢谢。这可能是一个原因。意味着 Heroku 正在寻找 ruby​​ 2.2.0。
  • 关键是remote: WARNING: You don't have /tmp/build_8786c086fcd09993475156f9d8f6a63a/.gem/ruby/2.2.0/bin in your PATH 我想我需要做的是设置正确的heroku ruby​​二进制安装的**path**,以便我的节点应用程序可以与compassgem通信。但是我不知道如何在 heroku 中设置 PATH
【解决方案2】:

我也刚开始遇到这个确切的问题,不确定 heroku 何时更改为 ruby​​ 2.2.0。这是我制作的用于修复 PATH 问题的 buildpack 的快速分支,https://github.com/adamgoldstein/heroku-buildpack-nodejs-grunt-compass

您可以在命令行上更改您的 buildpack: heroku buildpacks:set https://github.com/adamgoldstein/heroku-buildpack-nodejs-grunt-compass

【讨论】:

    猜你喜欢
    • 2014-07-16
    • 2021-07-07
    • 2012-10-12
    • 2018-07-29
    • 2020-10-20
    • 1970-01-01
    • 1970-01-01
    • 2012-11-26
    • 1970-01-01
    相关资源
    最近更新 更多