How to install Webpacker with Rails
Asked Answered
C

4

6

I'm trying to install Webpacker to be able to launch a Yarn server. I'm on Rails 5 and the gem is installed.

When I run

bundle exec rails webpacker:install

I get:

>> rails aborted!
Don't know how to build task 'webpacker:install' (see --tasks)
bin/rails:15:in `require'
bin/rails:15:in `<main>'
(See full trace by running task with --trace)

The command doesn't seem to exist.

Clevelandclevenger answered 2/12, 2017 at 7:54 Comment(1)
Maybe this will hep you > #47574725Higginson
D
7

install the rails/webpacker gem as from the documentation I am quoting

Installation

You can either add Webpacker during setup of a new Rails 5.1+ application using new --webpack option:

Available Rails 5.1+

rails new myapp --webpack
Or add it to your Gemfile:

Gemfile gem 'webpacker', '~> 3.0'

OR if you prefer to use master

gem 'webpacker', git: 'https://github.com/rails/webpacker.git'
and finally, run following to install Webpacker:

bundle
bundle exec rails webpacker:install

OR (on rails version < 5.0)

bundle exec rake webpacker:install
Dao answered 2/12, 2017 at 10:27 Comment(0)
N
5

First, add the following to the gemfile:

gem "webpacker", "~> 3"

Then, bundle install:

bundle exec rails webpacker:install
Nearly answered 4/3, 2020 at 6:4 Comment(1)
Please add some explanation to your answer by editing it, such that others can learn from itChanachance
U
4

I was trying to install webpacker and, for me, the solution was a bit different from those listed here.

I was trying gem install webpacker, but it doesn't change the Gemfile.

Then I searched for why it doesn't change, and to make it work I had to use:

bundle add webpacker

After that I used:

rails webpacker:install
Upsweep answered 26/1, 2022 at 12:2 Comment(0)
J
0

Are you sure webpacker is installed correctly?

Maybe there is an issue with your use of bundle exec try running without it. You can also try running with the --tasks flag to verify if the webpacker tasks are available to use.

Jodyjoe answered 2/12, 2017 at 8:59 Comment(2)
This command is not existing when i'm running --tasks. However I installed the gem so what can I do to make this command available ?Clevelandclevenger
If you run gem list is it listed under local gems?Jodyjoe

© 2022 - 2024 — McMap. All rights reserved.