Hijas ajmal
Hijas ajmal

Reputation: 151

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)

Upvotes: 15

Views: 9017

Answers (7)

dofstar
dofstar

Reputation: 11

npm ls -g

if no list yarn.

sudo npm install -g yarn --force

then

yarn --version

Upvotes: 1

Fatima
Fatima

Reputation: 355

I installed yarn by running sudo apt-get installed yarn on my POP OS(Ubuntu under the hood), and get the same error as yours.

Then, I have fixed this error by following the steps at yarn official page, https://classic.yarnpkg.com/en/docs/install/#debian-stable

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

Then, sudo apt-get update

Finally, sudo apt-get install yarn

Upvotes: 3

Andy Chen
Andy Chen

Reputation: 31

I confronted the same issue and resolved by installing yarn using nvm.

npm install -g yarn  

After installing and updating yarn to the current version, I have my Webpacker successfully installed.

Upvotes: 3

akotian
akotian

Reputation: 3935

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.

Upvotes: 24

Mathieu J.
Mathieu J.

Reputation: 2115

I should say this error was a step two error, I first had this other highly related problem Vanilla Rails 6.0: "error Command "webpack" not found" and then I was led here.

Here is what I did to solve it. +32 was indeed coming from yarn

$ yarn --version
0.32+git

I tried to find the lucky combination of node/npm/yarn/webpack but I never won anything at the lottery

so I removed yarn...

  • open your package.json in your favorite editor
  • make sure yarn is NOT there
  • delete yarn, or rename the binary
  • rails webpacker:install # now happy
  • rake assets:precompile # also happy
  • rails s # works fine again, I can use ActionCable finally.

Upvotes: 2

Try to update your Yarn version. Webpacker uses Yarn and it probably won't work with an old version, such as "0.32+git". When I updated my version, the problem got solved and I could run the rails application.

Upvotes: 0

Andy
Andy

Reputation: 114

If you put 0.32+git as version number please try using a numeric version number, eg: 0.32 (drop the +git)

Upvotes: 0

Related Questions