title: How to fix "Sprockets::FileNotFound: couldn't find file 'turbolinks' with type 'application/javascript'"
body: <p>I can't push my code to heroku but it works in local.
  When i make <code>rake assets:precompile</code> in terminal, i've this answer:
  <code>rake aborted!
  Sprockets::FileNotFound: couldn't find file 'turbolinks' with type 'application/javascript'</code> I don't want use Sprockets anymore</p>
  
  <p>I tryed this: <a href="https://www.innoq.com/en/blog/rails-custom-elements-with-turbolinks-webpack/" rel="nofollow noreferrer">https://www.innoq.com/en/blog/rails-custom-elements-with-turbolinks-webpack/</a></p>
  
  <p>but when i make :</p>
  
  <pre><code>class ApplicationController &lt; ActionController::Base
    include Turbolinks::Redirection
    # ...
  end
  </code></pre>
  
  <p>I've this error <code>uninitialized constant ApplicationController::Turbolinks</code> from error consol</p>
  
  <p>My application.js from app/javascript/packs/</p>
  
  <pre><code>import Turbolinks from 'turbolinks'
  Turbolinks.start()
  
  import '../css/application.scss'
  import 'bootstrap'
  </code></pre>
  
  <p>My package.json</p>
  
  <pre><code>{
    "name": "**********",
    "private": true,
    "dependencies": {
      "@rails/webpacker": "3.5",
      "bootstrap": "^4.2.1",
      "jquery": "^3.3.1",
      "popper.js": "^1.14.6",
      "turbolinks": "^5.2.0"
    },
    "devDependencies": {
      "webpack-dev-server": "2.11.2"
    },
    "version": "1.0.0",
    "main": "index.js",
    "repository": "git@github.com:******/*************.git",
    "author": "******* &lt;******@email.com&gt;",
    "license": "MIT"
  }
  </code></pre>
  
  <p>My Gemfile</p>
  
  <pre><code>source 'https://rubygems.org'
  git_source(:github) { |repo| "https://github.com/#{repo}.git" }
  
  ruby '2.6.0'
  
  # Bundle edge Rails instead: gem 'rails', github: 'rails/rails'
  gem 'rails', '~&gt; 5.2.2'
  gem 'pg', '&gt;= 0.18', '&lt; 2.0'
  gem 'puma', '~&gt; 3.11'
  gem 'webpacker'
  gem 'jbuilder', '~&gt; 2.5'
  gem 'simple_form'
  gem 'postmark-rails'
  gem 'cloudinary'
  gem 'dotenv-rails', groups: [:development, :test]
  gem 'rails_admin'
  gem 'turbolinks', require: false
  gem 'bootsnap', '&gt;= 1.1.0', require: false
  
  group :development, :test do
    gem 'byebug', platforms: [:mri, :mingw, :x64_mingw]
  end
  
  group :development do
    gem 'web-console', '&gt;= 3.3.0'
    gem 'listen', '&gt;= 3.0.5', '&lt; 3.2'
    gem 'spring'
    gem 'spring-watcher-listen', '~&gt; 2.0.0'
    gem 'better_errors'
    gem 'binding_of_caller'
    gem 'letter_opener'
  end
  
  group :test do
    gem 'capybara', '&gt;= 2.15'
    gem 'selenium-webdriver'
    gem 'chromedriver-helper'
  end
  </code></pre>
  
  <p>My webpacker.yml from app/config/webpack/</p>
  
  <pre><code>default: &amp;default
    source_path: app/javascript
    source_entry_path: packs
    public_output_path: packs
    cache_path: tmp/cache/webpacker
  
    # Additional paths webpack should lookup modules
    # ['app/assets', 'engine/foo/app/assets']
    resolved_paths: []
  
    # Reload manifest.json on all requests so we reload latest compiled packs
    cache_manifest: false
  
    extensions:
      - .js
      - .sass
      - .scss
      - .css
      - .module.sass
      - .module.scss
      - .module.css
      - .png
      - .svg
      - .gif
      - .jpeg
      - .jpg
  
  development:
    &lt;&lt;: *default
    compile: true
  
    # Reference: https://webpack.js.org/configuration/dev-server/
    dev_server:
      https: false
      host: localhost
      port: 3035
      public: localhost:3035
      hmr: false
      # Inline should be set to true if using HMR
      inline: true
      overlay: true
      compress: true
      disable_host_check: true
      use_local_ip: false
      quiet: false
      headers:
        'Access-Control-Allow-Origin': '*'
      watch_options:
        ignored: /node_modules/
  
  
  test:
    &lt;&lt;: *default
    compile: true
  
    # Compile test packs to a separate directory
    public_output_path: packs-test
  
  production:
    &lt;&lt;: *default
  
    # Production depends on precompilation of packs prior to booting for performance.
    compile: false
  
    # Cache manifest.json for performance
    cache_manifest: true
  </code></pre>
  
  <p>My application.html.erb from app/views/layouts</p>
  
  <pre><code>&lt;%= javascript_pack_tag 'application', 'data-turbolinks-eval': false, defer: true %&gt;
  &lt;%= stylesheet_pack_tag 'application', 'data-turbolinks-track': 'reload', defer: true %&gt;
  </code></pre>