Read more

How to fix "Command "webpack" not found"

Michael Leimstädtner
January 21, 2021Software engineer at makandra GmbH

I just ran into this deployment error after switching from the asset pipeline to webpack:

01:05 deploy:assets:precompile
      01 bundle exec rake assets:precompile
      01 Compiling...
      01 Compilation failed:
      01 yarn run v1.22.5
      01 error Command "webpack" not found.
rake stderr: Nothing written
Illustration UI/UX Design

UI/UX Design by makandra brand

We make sure that your target audience has the best possible experience with your digital product. You get:

  • Design tailored to your audience
  • Proven processes customized to your needs
  • An expert team of experienced designers
Read more Show archive.org snapshot

The problem is not related to the "webpack" dependency. You probably just forgot to add a binstub Show archive.org snapshot to run "yarn install":

Add these lines to "bin/yarn" and make it executable:

#!/usr/bin/env ruby
APP_ROOT = File.expand_path('..', __dir__)
Dir.chdir(APP_ROOT) do
  begin
    exec "yarnpkg", *ARGV
  rescue Errno::ENOENT
    $stderr.puts "Yarn executable was not detected in the system."
    $stderr.puts "Download Yarn at https://yarnpkg.com/en/docs/install"
    exit 1
  end
end

Deploying again should now install the missing dependencies as expected.

Posted by Michael Leimstädtner to makandra dev (2021-01-21 16:44)