Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

Webpacker Error on creating new rails app in rails 6

When i am creating new rails application i am getting error with webpacker (ArgumentError: Malformed version number string 0.32+git)

like image 803
Hijas ajmal Avatar asked Aug 24 '19 18:08

Hijas ajmal


People also ask

How do I add a Webpacker in Rails 6?

To include Webpacker in a new project, add --webpack to the rails new command. To add Webpacker to an existing project, add the webpacker gem to the project's Gemfile , run bundle install , and then run bin/rails webpacker:install . The installation also calls the yarn package manager, creates a package.


Video Answer


1 Answers

I was running into a similar issue running rails 6 on my Docker container. Turns out Rails 6 uses Webpacker, which needs yarn to be installed. Follow steps to install a newer version of Yarn

For Debian make sure these steps are followed

curl -sS https://dl.yarnpkg.com/debian/pubkey.gpg | sudo apt-key add -
echo "deb https://dl.yarnpkg.com/debian/ stable main" | sudo tee /etc/apt/sources.list.d/yarn.list

and then sudo apt update && sudo apt install yarn

This gave me yarn --version -> 1.19.1

after which sample rails new blog ran successfully, and added blog/config/webpacker.yml (Related to Vanilla Rails 6.0: "error Command "webpack" not found")

It is strange that the documentation does not mention yarn as a dependency.

like image 167
akotian Avatar answered Sep 19 '22 15:09

akotian