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

Command "webpack-dev-server" not found. #506

Closed
luispcosta opened this issue Jun 15, 2017 · 52 comments
Closed

Command "webpack-dev-server" not found. #506

luispcosta opened this issue Jun 15, 2017 · 52 comments

Comments

@luispcosta
Copy link

I'm trying to create a new project with webpacker in rails and I constantly get the error

yarn run v0.24.6
error Command "webpack-dev-server" not found.

When trying to launch the dev server.

Run down of the commands:

rails new testapp--webpack
./bin/rails webpacker:install:vue
./bin/webpack-dev-server
yarn run v0.24.6
error Command "webpack-dev-server" not found.

System configuration

  • Rails: 5.1.1
  • Ruby: 2.4.1p111
  • Node: v6.10.2
  • Yarn: v0.24.6
  • OS: Ubuntu 16.10

I'm also running this on a Vagrant machine with the version 1.9.3

I tried doing:

$ sudo npm install -g webpack-dev-server
$ npm install (from the rails project folder)
$ yarn
$  ./bin/yarn install

Nothing seems to work. Any help?

Thanks!

@gauravtiwari
Copy link
Member

@luispcosta Is webpacker installed i.e. config/webpack exists and all node_modules are bundled? Check node_modules folder please.

@luispcosta
Copy link
Author

luispcosta commented Jun 17, 2017

You're right. config/webpack doesn't exist. node_modules exists, and it contains webpack-dev-middleware and webpack-dev-server amongst other stuff.

What do I have to do to have config/webpack ?

Edit: Actually I do have the config/webpack folder.

@ytbryan
Copy link
Contributor

ytbryan commented Jun 18, 2017

@luispcosta you should do rails:webpacker:install

Because rails new testapp--webpack there is a missing space

Therefore, rails:webpacker:install not called. Therefore you don't have a config/webpack.

@gauravtiwari
Copy link
Member

Thanks @ytbryan. @luispcosta as suggested could you please re-run bundle exec rails webpacker:install and see if ./bin/webpack-dev-server works for you?

@gauravtiwari
Copy link
Member

Also could you please check your node_modules/.bin folder? See if you can run ./node_modules/.bin/webpack-dev-server manually (this won't work but just to check)

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
@gauravtiwari
Copy link
Member

@luispcosta Does the above suggestions work?

@luispcosta
Copy link
Author

Hey @gauravtiwari . Sorry for the late response, but no, it didn't work :\ I had the config/webpack folder all along, that wasn't the issue. I don't know if it is any problem related with yarn or node, but everything seems to be installed correctly. I even tried it from a new fresh rails project but it didn't work either. Not sure what's going on

@ytbryan
Copy link
Contributor

ytbryan commented Jun 22, 2017

@luispcosta can you push that fresh rails project on github ? and share with us?

@luispcosta
Copy link
Author

@ytbryan Sure, I can do it, but I can only do it later today. I'll ping here when I do it

@gauravtiwari
Copy link
Member

@luispcosta Seems like something to do with node or yarn. Are you able to manually run those executables? - ./node_modules/.bin/webpack-dev-server or yarn run webpack-dev-server

@gauravtiwari
Copy link
Member

@luispcosta Were you able to get this to work?

@ghost
Copy link

ghost commented Jul 25, 2017

I know this issue was closed, but I had the same problem.

In my case, the commands to configure wepacker didn't add the webpack-dev-server on the package.json, should it do it 🤔 ? I've solved it installing manually by yarn: yarn add webpack-dev-server.

@gauravtiwari
Copy link
Member

@frenangomes Yes if you have run bundle exec rails webpacker:install it should add that automatically for you. Perhaps the command exited prematurely due to an underlying error with node or yarn version. Could you check that please, trying running this command again - bundle exec rails webpacker:install?

@ghost
Copy link

ghost commented Jul 25, 2017

@gauravtiwari I had executed webpacker:install but it didn't add webpack-dev-server automatically. Testing it on another project it works very well, so I think it's a specific problem with my project, already I have updated Rails from 4.2 to 5.1.

I think the solution is this PR that was mentioned here. I didn't see it, my bad 😞 . I'll try it later.

@tarr11
Copy link

tarr11 commented Aug 16, 2017

I had this same problem (randomly - on a project that had been working fine for months) - I think it had something to do with npm messing up my node_modules.

Running bundle exec rails webpacker:install and clicking n to every suggestion worked fine for me.

@hovancik
Copy link

I have the same issue on docker. When I am on linux machine, everything works. On macOS, it does not. From my docker-compose.ym

command: bundle exec bin/webpack-dev-server
webpacker_1  | yarn run v0.27.5
webpacker_1  | error Command "webpack-dev-server" not found.
webpacker_1  | info Visit https://yarnpkg.com/en/docs/cli/run for documentation about this command.

ruby '2.4.1'
gem 'rails', '~> 5.1.3'

I created new app with

docker-compose build
docker-compose run web rails new . --force --database=postgresql --webpack=vue --skip-coffee --skip-turbolinks --skip-action-cable
docker-compose build

@gauravtiwari
Copy link
Member

@hovancik Could you please remove node_modules folder and do yarn install?

@gauravtiwari
Copy link
Member

Also you may want to use latest master where we have removed yarn run but for that you would need to reinstall webpacker. bundle exec rails webpacker:install after bundle update webpacker

Note: Also re-update webpacker.yml if you have changed the defaults after upgrade :)

@hovancik
Copy link

Thanks, works now with new yarn install.

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
@HarikrishnaDS
Copy link

I have installed yarn, foreman and also added it in Gemfile.
I create a Procfile as
rails: bundle exec rails server
webpack: bin/webpack-dev-server

When I run foreman start its showing error. I have been trying from 4 days couldn't find any solution to help me to fix this. Please help me!!!!!!!!!!!!!

C:\Sites\shine>foreman start
C:/RailsInstaller/Ruby2.3.3/lib/ruby/gems/2.3.0/gems/foreman-0.84.0/lib/foreman/process.rb:54:in spawn': Exec format error - bin/webpack-dev-server (Errno::ENOEXEC) from C:/RailsInstaller/Ruby2.3.3/lib/ruby/gems/2.3.0/gems/foreman-0.84.0/lib/foreman/process.rb:54:in block in run'
from C:/RailsInstaller/Ruby2.3.3/lib/ruby/gems/2.3.0/gems/foreman-0.84.0/lib/foreman/process.rb:53:in chdir' from C:/RailsInstaller/Ruby2.3.3/lib/ruby/gems/2.3.0/gems/foreman-0.84.0/lib/foreman/process.rb:53:in run'
from C:/RailsInstaller/Ruby2.3.3/lib/ruby/gems/2.3.0/gems/foreman-0.84.0/lib/foreman/engine.rb:366:in block (2 levels) in spawn_processes' from C:/RailsInstaller/Ruby2.3.3/lib/ruby/gems/2.3.0/gems/foreman-0.84.0/lib/foreman/engine.rb:363:in upto'
from C:/RailsInstaller/Ruby2.3.3/lib/ruby/gems/2.3.0/gems/foreman-0.84.0/lib/foreman/engine.rb:363:in block in spawn_processes' from C:/RailsInstaller/Ruby2.3.3/lib/ruby/gems/2.3.0/gems/foreman-0.84.0/lib/foreman/engine.rb:362:in each'
from C:/RailsInstaller/Ruby2.3.3/lib/ruby/gems/2.3.0/gems/foreman-0.84.0/lib/foreman/engine.rb:362:in spawn_processes' from C:/RailsInstaller/Ruby2.3.3/lib/ruby/gems/2.3.0/gems/foreman-0.84.0/lib/foreman/engine.rb:57:in start'
from C:/RailsInstaller/Ruby2.3.3/lib/ruby/gems/2.3.0/gems/foreman-0.84.0/lib/foreman/cli.rb:42:in start' from C:/RailsInstaller/Ruby2.3.3/lib/ruby/gems/2.3.0/gems/thor-0.19.4/lib/thor/command.rb:27:in run'
from C:/RailsInstaller/Ruby2.3.3/lib/ruby/gems/2.3.0/gems/thor-0.19.4/lib/thor/invocation.rb:126:in invoke_command' from C:/RailsInstaller/Ruby2.3.3/lib/ruby/gems/2.3.0/gems/thor-0.19.4/lib/thor.rb:369:in dispatch'
from C:/RailsInstaller/Ruby2.3.3/lib/ruby/gems/2.3.0/gems/thor-0.19.4/lib/thor/base.rb:444:in start' from C:/RailsInstaller/Ruby2.3.3/lib/ruby/gems/2.3.0/gems/foreman-0.84.0/bin/foreman:7:in <top (required)>'
from C:/RailsInstaller/Ruby2.3.3/bin/foreman:23:in load' from C:/RailsInstaller/Ruby2.3.3/bin/foreman:23:in

'

@gauravtiwari
Copy link
Member

Have you installed webpacker after adding to your Gemfile?

bundle exec rails webpacker:install

@HarikrishnaDS
Copy link

HarikrishnaDS commented Mar 11, 2018

@gauravtiwari Yes I had executed the same command and when I run foreman start still getting the same error.
I even executed bundle install command too.

My gemfile looks like
capture1 gemfile

Attached image after executing bundle exec rails webpacker:install
capture1

@gauravtiwari
Copy link
Member

What happens if you run bundle exec rails webpacker:binstubs?

@HarikrishnaDS
Copy link

@gauravtiwari I executed the command you sent the result is attached below
capture2 binstubs

@gauravtiwari
Copy link
Member

Ahh right so it's there. Could you please run it like so: ruby ./bin/webpack-dev-server from Procfile?

@HarikrishnaDS
Copy link

@gauravtiwari It's throwing some error as;
capture3

@gauravtiwari
Copy link
Member

Ahh right so it seems you got the latest dev server installed which is only works with 4.0. Please could you do: yarn add [email protected] and then run the command.

@HarikrishnaDS
Copy link

I executed yarn add [email protected] it installs few packages. Then I executed ruby ./bin/webpack-dev-server it runs successfully.
capture4

Then I run foreman start still its showing same error.

@gauravtiwari
Copy link
Member

What error are you getting with foreman start ? Have you changed foreman command to use ruby ./bin/webpack-dev-server?

@HarikrishnaDS
Copy link

@gauravtiwari I changed my Procfile as
capture5
Then when I run foreman start it shows error as
capture6

@gauravtiwari
Copy link
Member

Looks like there is some syntax error in Gemfile on line 13.

@HarikrishnaDS
Copy link

@gauravtiwari At line 13 there was gem 'devise'. I removed it and run foreman start now its showing
capture7

But localhost:5000 not working in browser

@gauravtiwari
Copy link
Member

What happens if you run bundle exec rails s? - looks like since you removed devise, there might be configuration still present in config/initializers. It was actually some syntax issue probably the quote was wrong in the Gemfile, so fix that instead of removing devise.

@HarikrishnaDS
Copy link

@gauravtiwari bundle exec rails s is working fine after removing gem 'devise'. I can open localhost:3000 in browser successfully.

But when I add gem 'devise' in Gem file, if i run bundle exec rails s it's showing errors as
capture8

@gauravtiwari
Copy link
Member

Not sure what's wrong there. Can you manually type gem 'devise' into your Gemfile? (make sure quotes are correct)

@HarikrishnaDS
Copy link

@gauravtiwari I changed its position i.e., after gem 'rails' and run bundle install. Now bundle exec rails s is working fine.
But when i run foreman start its not showing any http port i.e. localhost:5000. It's showing as I send a screenshot earlier as
capture9

@abineetds
Copy link

Facing the same issue. Any solution to this?

@gauravtiwari
Copy link
Member

Could you please make an example repo?

@abineetds
Copy link

abineetds commented Apr 4, 2018

https://bitbucket.org/abineetds/qiggleonrails
I can run the rails server but am having the same issue when trying to run foreman to run webpack-dev-server simultaneously.
I'm running on a 64-bit Windows 10 machine.

@juantoniomac
Copy link

@abineetds could you find a solution for your issue? I have exactly the same issue in Windows 10 machine too

@abineetds
Copy link

Sadly no. Just not using hot reloading at the moment. Slow, but works.

@gauravtiwari
Copy link
Member

@abineetds Are you able to run webpack dev server without foreman?

ruby ./bin/webpack-dev-server

@abineetds
Copy link

abineetds commented Apr 10, 2018

Yes it does run, but on navigating to localhost:3035, I get what looks like a routing error. no GET for /.
I got past the ENOEXEC error in foreman, by using this.
webpacker: ruby ./bin/webpack-dev-server

Now what I see is this:

13:00:07 web.1       | started with pid 9772
13:00:07 webpacker.1 | started with pid 20120
13:00:10 webpacker.1 | exited with code 0
13:00:10 system      | sending SIGKILL to all processes
13:00:10 system      | sending SIGKILL to web.1 at pid 9772
13:00:10 web.1       | exited with code 0

@gauravtiwari
Copy link
Member

You don't need to go to localhost:3035 if dev server is running fine. Try navigating to rails s url:

Run following in separate terminal windows (without foreman):

bundle exec rails s
ruby ./bin/webpack-dev-server

Navigate to localhost:3000 or whatever rails s URL is.

The home views should load javascript/packs if you have included javascript_pack_tag to it.

@gauravtiwari
Copy link
Member

gauravtiwari commented Apr 10, 2018

Have you tried invoker or https://github.com/ddollar/forego on windows?

@abineetds
Copy link

abineetds commented Apr 10, 2018

Hey @gauravtiwari,

That actually worked. I'm just running rails s in one Powershell window and ruby ./bin/webpack-dev-server in another.

Thanks a ton! I'll try out your other recommendations too.

@juantoniomac This might work for you.

@kingpalethe
Copy link

Interestingly, this issue was closed but recently sprang to life, and I am having a similar problem (really more of "syndrome") which I have reported in this issue: #1419

@christiangenco
Copy link

I was missing a package.json file, which wasn't getting initialized when I ran rails webpacker:install.

Running yarn init, then rails webpacker:install added these dependencies:

  "dependencies": {
    "@rails/webpacker": "3.5"
  },
  "devDependencies": {
    "webpack-dev-server": "2.11.2"
  }

and then bin/webpack-dev-server worked.

@diegocharles
Copy link

diegocharles commented Jan 20, 2019

I was missing a package.json file, which wasn't getting initialized when I ran rails webpacker:install.

Running yarn init, then rails webpacker:install added these dependencies:

  "dependencies": {
    "@rails/webpacker": "3.5"
  },
  "devDependencies": {
    "webpack-dev-server": "2.11.2"
  }

and then bin/webpack-dev-server worked.

That worked fine to me, Thanks. What's the login here? I'm using rails 5.2.2 and I thought rails:webpacker:install was supposed to do all the job.

@gsum
Copy link

gsum commented Mar 4, 2019

for me command yarn did the trick.

@gouthamganesh9889
Copy link

ruby ./bin/webpack-dev-server

When I run this it says no such file or directory. Any idea what I should do? Thanks

mzagaja added a commit to MAPC/trailmap3 that referenced this issue Aug 9, 2019
Install webpacker in dependencies instead of devDependencies per rails/webpacker#506 (comment)
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
@koroglumert
Copy link

It's 2023 and I'm having this problem and I still can't solve it. Even the npm install webpack-dev-server -g suggestion didn't work.
I'm trying to uninstall the open source project on macOS. My two containers give the error sh: webpack-dev-server: not found. Can anyone help me?

project:
https://github.com/OneUptime/oneuptime/tree/release

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