webpacker: Command "webpack" not found.
I’m deploying an upgraded Rails 4.x -> 5.1 app to Heroku and am getting the error
Command "webpack" not found.
I’ve gone on to the dyno directly and attempted to run rake assets:precompile
which fails with the message:
Webpacker is installed 🎉 🍰
Using /app/config/webpacker.yml file for setting up webpack paths
[Webpacker] Compiling assets 🎉
[Webpacker] Compilation Failed
yarn run v0.22.0
info Visit https://yarnpkg.com/en/docs/cli/run for documentation about this command.
error Command "webpack" not found.
This seems to be coming from https://github.com/rails/webpacker/blob/f35331c678c7fd44ef225553629ee3e14989030e/lib/tasks/webpacker/compile.rake#L13
Am I correct in understanding that executing rake assets:precompile
is all that needs to occur for a deployment? ie, that handles installing the yarn dependencies etc?
I found that if I do yarn install
first and then assets:precompile
it works - but I didn’t think I had to do that.
~ $ rake webpacker:verify_install
Webpacker is installed 🎉 🍰
Using /app/config/webpacker.yml file for setting up webpack paths
About this issue
- Original URL
- State: closed
- Created 7 years ago
- Reactions: 18
- Comments: 30 (20 by maintainers)
Commits related to this issue
- webpack or webpack-dev-server not found (#516) * webpack or webpack-dev-server not found Add to troubleshooting of readme to prevent such issues https://github.com/rails/webpacker/issues/379#issue... — committed to rails/webpacker by ytbryan 7 years ago
- Add bin/yarn per https://github.com/rails/webpacker/issues/522 and reference from bin/setup. — committed to SplitTime/OpenSplitTime by moveson 7 years ago
- webpack or webpack-dev-server not found (#516) * webpack or webpack-dev-server not found Add to troubleshooting of readme to prevent such issues https://github.com/rails/webpacker/issues/379#issue... — committed to sensiblegame/webpack by sensiblegame 7 years ago
- Fixed Webpacker::Manifest::MissingEntryError error Command "webpack" not found. - bundle exec rails webpacker:install - https://github.com/rails/webpacker/issues/522#issuecomment-328985202 — committed to x1wins/CW-OVP by x1wins 4 years ago
- Merge branch 'feature/webpacker-error' into develop * feature/webpacker-error: Fixed Webpacker::Manifest::MissingEntryError error Command "webpack" not found. - bundle exec rails webpacker:install ... — committed to x1wins/CW-OVP by x1wins 4 years ago
- webpack or webpack-dev-server not found (#516) * webpack or webpack-dev-server not found Add to troubleshooting of readme to prevent such issues https://github.com/rails/webpacker/issues/379#issue... — committed to KingTiger001/Rails-web-pack-project by KingTiger001 7 years ago
- Fixed Webpacker::Manifest::MissingEntryError error Command "webpack" not found. - bundle exec rails webpacker:install - https://github.com/rails/webpacker/issues/522#issuecomment-328985202 — committed to Simba830/cw_ovp by deleted user 4 years ago
- Merge branch 'feature/webpacker-error' into develop * feature/webpacker-error: Fixed Webpacker::Manifest::MissingEntryError error Command "webpack" not found. - bundle exec rails webpacker:install ... — committed to Simba830/cw_ovp by deleted user 4 years ago
- webpack or webpack-dev-server not found (#516) * webpack or webpack-dev-server not found Add to troubleshooting of readme to prevent such issues https://github.com/rails/webpacker/issues/379#issue... — committed to smartech7/ruby-webpacker by ytbryan 7 years ago
For anyone updating from Rails 4.x to 5.1.x to add yarn binstub -
@jnfeinstein Just install webpacker,
bundle exec rails webpacker:install
. Also you would need to remove ./bin folder from.gitignore
thank you @jakeNiemiec ,
bundle exec rails webpacker:install
adds it todependencies
but I will edit and clearify my comment.In my case
rails webpacker:install
was silently ‘failing’. When I checknode_modules/.bin
folder there was nowebpack
file and this results in theCommand "webpack" not found.
error. (webpack source code reference)After some investigation, I manually tried to add webpack using ~
yarn add --dev webpack webpack-dev-server
~yarn add webpack webpack-dev-server
command and saw the below error(webpack module cant be installed because of some DNS related problem).error An unexpected error occurred: "https://registry.npmjs.org/webpack: Hostname/IP does not match certificate's altnames: Host: registry.npmjs.org. is not in the cert's altnames: DNS:a.sni.fastly.net, DNS:a.sni.global-ssl.fastly.net".
After some research, the above problem is solved with the command below.
dig https://registry.npmjs.org/webpack @1.1.1.1
Then, I remove node_modules, and generate it once more using
bundle exec rails webpacker:install
. This time I’ve hadnode_modules/.bin/webpack
file and the error was fixed.when error happens with capistrano:
@ytbryan the buildpack maintainer here. You do not need to use the Node buildpack.
Looks like it’s only gets generated with
rails new
(5.1+) - https://github.com/rails/rails/blob/801b33a4812c937a7e726d4060e2e3e9361c56fa/railties/lib/rails/generators/rails/app/templates/bin/yarnSeems like the task is invoked but there is no yarn binstub present since you were using Rails 4.
Please regenerate them -
bundle install --binstubs
You need run task yarn install before assets:precompile.
Look at documentation
https://github.com/rails/webpacker/blob/master/docs/deployment.md