Rails app cannot compile js : (No route matches [GET] "/packs/application-xxxx.js"):

Viewed 7226

my js is not compiled anymore on my rails app in development mode :

Here is the console error :

GET http://localhost:3000/packs/application-6b30daaa0a66e7f7c4fd.js 404 (Not Found)

Here are my logs :

Started GET "/packs/application-6b30daaa0a66e7f7c4fd.js" for 127.0.0.1 at 2018-12-18 21:40:35 +0100

ActionController::RoutingError (No route matches [GET] "/packs/application-6b30daaa0a66e7f7c4fd.js"):

actionpack (5.1.5) lib/action_dispatch/middleware/debug_exceptions.rb:63:in `call'
web-console (3.5.1) lib/web_console/middleware.rb:135:in `call_app'
web-console (3.5.1) lib/web_console/middleware.rb:28:in `block in call'
web-console (3.5.1) lib/web_console/middleware.rb:18:in `catch'
web-console (3.5.1) lib/web_console/middleware.rb:18:in `call'
actionpack (5.1.5) lib/action_dispatch/middleware/show_exceptions.rb:31:in `call'
railties (5.1.5) lib/rails/rack/logger.rb:36:in `call_app'
railties (5.1.5) lib/rails/rack/logger.rb:24:in `block in call'
activesupport (5.1.5) lib/active_support/tagged_logging.rb:69:in `block in tagged'
activesupport (5.1.5) lib/active_support/tagged_logging.rb:26:in `tagged'
activesupport (5.1.5) lib/active_support/tagged_logging.rb:69:in `tagged'
railties (5.1.5) lib/rails/rack/logger.rb:24:in `call'
sprockets-rails (3.2.1) lib/sprockets/rails/quiet_assets.rb:13:in `call'
actionpack (5.1.5) lib/action_dispatch/middleware/remote_ip.rb:79:in `call'
actionpack (5.1.5) lib/action_dispatch/middleware/request_id.rb:25:in `call'
rack (2.0.4) lib/rack/method_override.rb:22:in `call'
rack (2.0.4) lib/rack/runtime.rb:22:in `call'
activesupport (5.1.5) lib/active_support/cache/strategy/local_cache_middleware.rb:27:in `call'
actionpack (5.1.5) lib/action_dispatch/middleware/executor.rb:12:in `call'
actionpack (5.1.5) lib/action_dispatch/middleware/static.rb:125:in `call'
rack (2.0.4) lib/rack/sendfile.rb:111:in `call'
webpacker (3.2.2) lib/webpacker/dev_server_proxy.rb:18:in `perform_request'
rack-proxy (0.6.3) lib/rack/proxy.rb:57:in `call'
railties (5.1.5) lib/rails/engine.rb:522:in `call'
puma (3.11.2) lib/puma/configuration.rb:225:in `call'
puma (3.11.2) lib/puma/server.rb:624:in `handle_request'
puma (3.11.2) lib/puma/server.rb:438:in `process_client'
puma (3.11.2) lib/puma/server.rb:302:in `block in run'
puma (3.11.2) lib/puma/thread_pool.rb:120:in `block in spawn_thread'

Here are my package.json dependencies :

"devDependencies": {
    "webpack": "^4.27.1",
    "webpack-cli": "^3.1.2",
    "webpack-dev-server": "^3.1.10"
  }

It was working perfectly fine before I played a bit with yarn and npm as I was trying to fix another bug. Do you have any idea of the problem?

4 Answers

Did you run ./bin/webpack before started the Rails server?

Run bundle exec ./bin/webpack-dev-server before starting rails s

After hours, i found my error.

I was missing a comma in environment.js :

const { environment } = require('@rails/webpacker')

const webpack = require('webpack')
environment.plugins.prepend('Provide',
  new webpack.ProvidePlugin({
    $: 'jquery',
    jQuery: 'jquery',
    Popper: ['popper.js', 'default'],
    noUiSlider: 'nouislider'
  })
)

module.exports = environment

Thanks a lot everybody

Try running in your terminal:

  1. ./bin/webpack
  2. ./bin/webpack-dev-server or
  3. Yarn

The steps I run to start a new project are:

  1. git clone
  2. bundle install
  3. db:migrate
  4. Yarn
  5. Rails s
Related