Search code examples
herokubrowserifysprocketsreact-rails

Heroku Production - ActionView::Template::Error (undefined method `directory' for #<Sprockets::Manifest:number>)


We have a react-rails app. Unfortunately, the app works on local development but not when deployed to heroku. When going to our default path on the app, we get the following error: ActionView::Template::Error (undefined method 'directory' for #<Sprockets::Manifest:0x007fef13200aa8>)

We've figured out that it happens at this line in our view: <%= react_component('NavBar', {}, {prerender: true}) %>

A few things about our app:

  • It uses browserify to compile our js.jsx.
  • We precompile using RAILS_ENV=production bundle exec rake assets:precompile after deleting the public/assets folder.
  • Works locally with both rails s and foreman start
  • We are using boostrap-sprockets. Even when removed, we still have this issue.

Here is our npm dependencies:

"dependencies": {
   "browserify": "^10.2.4",
   "browserify-incremental": "^1.5.0",
   "classnames": "^2.2.3",
   "reactify": "^1.1.0"
}

Here is our Gemfile

    source 'https://rubygems.org'
    gem 'rails', '4.2.3'
    gem 'rails-api'
    gem 'spring', :group => :development
    gem 'active_model_serializers', '~> 0.10.0.rc1'
    gem 'pg'
    gem 'devise'
    gem 'puma'
    gem 'twitter'
    gem 'react-rails', '~> 1.0'
    gem 'browserify-rails', '~> 0.9.1'
    gem 'bootstrap-sass', '~> 3.2.0'
    gem 'sass-rails', '~> 5.0', '>= 5.0.4'
    gem 'autoprefixer-rails'
    group :test  do
      gem 'rspec-rails'
      gem 'pry'
      gem 'faker'
      gem 'webmock'
    end
    group :development, :test do
      gem 'factory_girl_rails'
    end
    group :production do
      gem 'uglifier'
      gem 'rails_12factor'
      gem 'rspec'
    end
    ruby '2.2.4'

We would appreciate all help.


Solution

  • The solution from hours of searching on StackOverflow and github issues seems to be to remove

    //= require react_ujs
    

    from your application.js in your assets folder.