Deploy Rails app with browserify-rails to Heroku

I am building Rails 4.x app that runs on Heroku. And I recently added browserify-rails to the app then I got an error below while deploying it to Heroku.

BrowserifyRails::BrowserifyError: browserify could not be found at /tmp/build_7afd0a3da809f3510421bfa4737d3bf8/./node_modules/.bin/browserify. Please run npm install.

I've tried a lot of thing and finally found the solution. Here is the process for solving this issue.

Configure Heroku to use multi-buildpack

heroku config:add BUILDPACK_URL=https://github.com/ddollar/heroku-buildpack-multi.git

Create .buildpacks file

Create .buildpacks file for the multi-buildpack to make sure node.js is compiled before ruby.

https://github.com/heroku/heroku-buildpack-nodejs
https://github.com/heroku/heroku-buildpack-ruby

Install browserify with --save

rake assets:precompile in heroku deploy expects browserify to be installed in .node_modules directory. So move it from devDependencies to dependencies.

npm uninstall browserify --save-dev
npm install browserify --save

Now try to deploy again!

git push heroku master

It should work now.

comments powered by Disqus