Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

webpacker is installed... ./bin/webpack: not found #379

Closed
christophermlne opened this issue May 13, 2017 · 16 comments
Closed

webpacker is installed... ./bin/webpack: not found #379

christophermlne opened this issue May 13, 2017 · 16 comments

Comments

@christophermlne
Copy link

I'm not sure how to interpret this error that I get when trying to precompile assets on the server.

  1. webpacker is installed
  2. but webpack is not found
  3. A JSON text must at least contain two octets! (thanks but which JSON file?)
app@vagrant:/var/www/app/application$ bundle exec rake assets:precompile
Webpacker is installed 🎉 🍰
Using /var/www/app/application/config/webpack/paths.yml file for setting up webpack paths
Compiling webpacker assets 🎉
sh: 1: ./bin/webpack: not found
rake aborted!
JSON::ParserError: A JSON text must at least contain two octets!
/home/app/.rbenv/versions/2.3.1/bin/bundle:23:in `load'
/home/app/.rbenv/versions/2.3.1/bin/bundle:23:in `<main>'
Tasks: TOP => webpacker:compile
(See full trace by running task with --trace)
@christophermlne christophermlne changed the title webpacker is installed. ./bin/webpack: not found webpacker is installed... ./bin/webpack: not found May 13, 2017
@btc
Copy link
Contributor

btc commented May 13, 2017

Perhaps you need to run yarn to get your dependencies loaded into node_modules.

@christophermlne
Copy link
Author

@btc i just tried your suggestion but unfortunately it didn't work. i get the same error.

this line https://github.com/rails/webpacker/blob/master/lib/tasks/webpacker/compile.rake#L11
is allowed to execute after webpacker:verify_install succeeds. i'm wondering if webpacker:verify_install ought to have failed here, since a working webpack installation doesn't seem to be present? (even though i can run 'webpack' in the terminal and it works)

@ytbryan
Copy link
Contributor

ytbryan commented May 13, 2017

What's your rails version? Are you using rails 5? I think it's because you are lacking the binstub webpack in your bin folder.

And what's your webpacker's version?

@christophermlne
Copy link
Author

christophermlne commented May 13, 2017

@ytbryan you are right. i have a bin folder on my local machine but not on the remote server.

my webpacker version is 1.2, my rails version is 5.0.2 (i am blocked from upgrading to 5.1.0 by a dependency)

@christophermlne
Copy link
Author

christophermlne commented May 13, 2017

i ran bundle exec bin/rails app:update:bin and so now i have a bin folder.
i still get the same error though (there is no webpack binstub in the folder).

ok, so the problem seems to be that the auto-generated .gitignore file from rails 4.x has the bin folder in the .gitignore file. i'm going to play around with not .gitignoring the bin folder and see if that resolves the issue

@christophermlne
Copy link
Author

the issue was caused by the bin folder not being present, and updating the .gitignore file and redeploying fixed it.

@raldred
Copy link

raldred commented May 31, 2017

What's the solution for getting the webpack binstubs? in a rails 5.0.2 app? same as OP can't upgrade to 5.1 yet.
no ./bin in gitignore
ran yarn
bundle exec bin/rails app:update:bin runs no ./bin/webpack created
rails webpacker:install:react errors Webpack binstubs not found.

@ytbryan
Copy link
Contributor

ytbryan commented May 31, 2017

@raldred Did you run rails webpacker:install ? Which version of webpacker are you using?

@raldred
Copy link

raldred commented May 31, 2017

Doh. '~> 2.0'. I guess I assumed webpacker:install:react would bootstrap it all. Sorry for wasting your time.

@TangMonk
Copy link

TangMonk commented Jun 3, 2017

@raldred , same problem, I am assumed webpacker:install:react would auto generate all config files

@kevgathuku
Copy link

kevgathuku commented Jun 12, 2017

I also experienced this issue while trying to add webpacker to an existing rails app.
The solution I used was to run the webpacker:installscript first
Then after that was done, I ran webpacker:install:react which added the files I needed.

Trying to run webpacker:install:react first caused the error that brought me here in the first place 😄

gauravtiwari pushed a commit that referenced this issue Jun 21, 2017
* webpack or webpack-dev-server not found

Add to troubleshooting of readme to prevent such issues #379 (comment), #506

* Update README.md

* Update README.md

* Include solution for error occurring in heroku

* Update README.md

Since it is known that node buildpacks is not necessary Read: #522 (comment)

* Update README.md

* Update README.md

Include instruction while upgrading from rails 4 to 5.

* Minor update

* Use ./bin/rails

* Add as comment
@kwerle
Copy link

kwerle commented Sep 15, 2017

Running rails 4.2. I also had to
rake webpacker:install
before
rake webpacker:install:vue

sensiblegame added a commit to sensiblegame/webpack that referenced this issue Oct 23, 2017
* webpack or webpack-dev-server not found

Add to troubleshooting of readme to prevent such issues rails/webpacker#379 (comment), rails/webpacker#506

* Update README.md

* Update README.md

* Include solution for error occurring in heroku

* Update README.md

Since it is known that node buildpacks is not necessary Read: rails/webpacker#522 (comment)

* Update README.md

* Update README.md

Include instruction while upgrading from rails 4 to 5.

* Minor update

* Use ./bin/rails

* Add as comment
@daryllxd
Copy link

I had this problem (.bin/webpack not found), but I think I had a different case. Turns out I wasn't npm installing the webpack commands. I added capistrano-npm to my deploy process and it works. Might help someone

mzagaja added a commit to MAPC/roadworks that referenced this issue Apr 3, 2018
Follow pattern at rails/webpacker#379 (comment) to attempt to fix webpack.
@Hazelwu2
Copy link

I also has the same problem, and I reinstall

rails webpacker:install

many time >"<

@thanhtruong1216
Copy link

I also having the issues.

@AntonAL
Copy link

AntonAL commented Apr 1, 2019

Install webpack manually on your server:

  1. Add webpack to package.json – yarn add webpack webpack-cli;
  2. In your server go to a folder of current release, that was failed and do yarn:
cd /var/www/your_project/releases/your_release_timestamp
yarn
  1. Try to deploy – bundle exec cap production deploy

KingTiger001 added a commit to KingTiger001/Rails-web-pack-project that referenced this issue Jan 15, 2023
* webpack or webpack-dev-server not found

Add to troubleshooting of readme to prevent such issues rails/webpacker#379 (comment), rails/webpacker#506

* Update README.md

* Update README.md

* Include solution for error occurring in heroku

* Update README.md

Since it is known that node buildpacks is not necessary Read: rails/webpacker#522 (comment)

* Update README.md

* Update README.md

Include instruction while upgrading from rails 4 to 5.

* Minor update

* Use ./bin/rails

* Add as comment
smartech7 pushed a commit to smartech7/ruby-webpacker that referenced this issue Aug 4, 2023
* webpack or webpack-dev-server not found

Add to troubleshooting of readme to prevent such issues rails/webpacker#379 (comment), rails/webpacker#506

* Update README.md

* Update README.md

* Include solution for error occurring in heroku

* Update README.md

Since it is known that node buildpacks is not necessary Read: rails/webpacker#522 (comment)

* Update README.md

* Update README.md

Include instruction while upgrading from rails 4 to 5.

* Minor update

* Use ./bin/rails

* Add as comment
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests