Rails: Vanilla Rails 6.0 error Command "webpack" not found Rails: Vanilla Rails 6.0 error Command "webpack" not found ruby-on-rails ruby-on-rails

Rails: Vanilla Rails 6.0 error Command "webpack" not found


I faced the same issue. And tried running bundle exec rails webpacker:install as suggested by @AFOC 's answer. Then I realized my node version wasn't compatible with rails/webpacker. Then used node 12.x. it works.

I also I retried by deleting the whole app, creating the app again, did not face the issue again, it worked the first time. So in my case, it was node version.


EDIT:

This is one of my first posts, so forgive me if I get the posting conventions wrong.

The problem comes from the version of node on your local computer. When you created your rails app, you probably had an error like this pop up:

The JavaScript app source directory already exists   apply  /Users/mconiaris/.rbenv/versions/2.6.4/lib/ruby/gems/2.6.0/gems/webpacker-4.0.7/lib/install/binstubs.rb  Copying binstubs       exist    bin      create    bin/webpack      create    bin/webpack-dev-server      append  .gitignoreInstalling all JavaScript dependencies [4.0.7]         run  yarn add @rails/webpacker from "."yarn add v1.17.3info No lockfile found.[1/4] 🔍  Resolving packages...warning @rails/webpacker > postcss-preset-env > postcss-color-functional-notation > postcss-values-parser > flatten@1.0.2: I wrote this module a very long time ago; you should use something else.[2/4] 🚚  Fetching packages...error get-caller-file@2.0.5: The engine "node" is incompatible with this module. Expected version "6.* || 8.* || >= 10.*". Got "9.4.0"error Found incompatible module.info Visit https://yarnpkg.com/en/docs/cli/add for documentation about this command.

In my case, I had version 9.4.0 of node installed on my computer, and that was the one version the get-caller-file package did not want to work with.

To fix the problem, first confirm your version of node to ensure that it's not 9.x.x:

node -v

Update node (I use nvm, but there are other ways on GitHub on the node Website).

nvm install node # "node" is an alias for the latest version

Check the version again. If it's 12.10 or higher, you should be all set.

Go start another brand new rails project and it should work fine.

Good luck!


I had to same challenge when trying to set up a new Rails 6 application in Ubuntu 20.04.

When I start the rails server, I get the error:

error Command "webpack" not found.info Visit https://yarnpkg.com/en/docs/cli/run for documentation about this command.09:17:58 webpacker.1 | exited with code 109:17:58 system      | sending SIGTERM to all processes09:17:58 watcher.1   | exited with code 109:17:58 web.1       | terminated by SIGTERM

Here's how I fixed it:

The issue for me was due to poor internet connectivity, which did not permit the full installation of webpacker and all of its dependencies. So each time I run the command:

bundle exec rails webpacker:install

I get this output:

Installing all JavaScript dependencies [4.3.0]         run  yarn add @rails/webpacker@4.3.0 from "."yarn add v1.22.5[1/4] Resolving packages...info There appears to be trouble with your network connection. Retrying...info There appears to be trouble with your network connection. Retrying...

I simply had to move to an area with better internet connectivity, and then I ran the command:

bundle exec rails webpacker:install

OR

rails webpacker:install

This time, it ran successfully and installed webpacker and all of its dependencies, and it gave me this final output:

[4/4] Building fresh packages...success Saved 1 new dependency.info Direct dependencies└─ webpack-dev-server@3.11.0info All dependencies└─ webpack-dev-server@3.11.0Done in 5.90s.

That's all.

I hope this helps