Skip to content

javascript_dir': undefined method source_path' for Webpacker::Configuration:Class (NoMethodError) #778

@vikash22292

Description

@vikash22292

I am trying to install 'react-rails' with 'webpacker'. I added both this gems in my rails gemfile. Versions for ruby, rails & gems are as follows:-

  1. Ruby: 2.4.1
  2. Rails: 5.1
  3. react-rails gem: 2.2.1
  4. webpacker: 3.0.0

I am not able to run "rails generate react:install" command to generate components/ directory for my React components.

I found that there was an issue in "react-rails-2.2.1/lib/generators/react/install_generator.rb" file for javascript_dir method.

Earlier code:-
def javascript_dir
if webpacker?
Webpacker::Configuration.source_path
.join(Webpacker::Configuration.entry_path)
.relative_path_from(::Rails.root)
.to_s
else
'app/assets/javascripts'
end
end

Code to fix:
def javascript_dir
if webpacker?
Webpacker.config.source_path
.join(Webpacker.config.source_entry_path)
.relative_path_from(::Rails.root)
.to_s
else
'app/assets/javascripts'
end
end

The term Webpacker::Configuration is chnaged to Webpacker.config and method name entry_path is changed to source_entry_path.

This work for me..!! Hope this works for you guys!

Metadata

Metadata

Assignees

No one assigned

    Labels

    No labels
    No labels

    Type

    No type

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions