如何使用gruntfile将node js app部署到heroku

时间:2015-08-13 11:35:56

标签: javascript ruby node.js heroku gruntjs

我正在尝试使用BUILDPACK_URL将节点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已经安装在本地机器中的compass宝石。

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

任何人都可以告诉如何克服这个问题并正确设置gem的PATH变量。

非常感谢。

2 个答案:

答案 0 :(得分:1)

我只是查看了buildback源代码并在bin / compile中看到两次,它引用了ruby 1.9.1。两次设置环境变量。

也许heroku在节点buildpack中升级了ruby的版本?

我会将repo分叉并将值更改为正在查找的2.2.0路径值。

您只需要更改buildpack中的路径,或者按照注释中的说明进行操作。

答案 1 :(得分:1)

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

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