webpacker: Command "webpack-dev-server" not found.

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!

About this issue

  • Original URL
  • State: closed
  • Created 7 years ago
  • Reactions: 17
  • Comments: 52 (23 by maintainers)

Commits related to this issue

Most upvoted comments

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?

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.

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.

for me command yarn did the trick.

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

@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.

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.

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

@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?