`javascript_dir': undefined method `source_path' for Webpacker::Configuration:Class (NoMethodError)
See original GitHub issueI 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:-
- Ruby: 2.4.1
- Rails: 5.1
- react-rails gem: 2.2.1
- 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!
Issue Analytics
- State:
- Created 6 years ago
- Reactions:9
- Comments:8 (1 by maintainers)
Had the same issue, the current master branch fixed it.
The fix you suggested worked for me.