Webpacker can’t find script

I have a .html.erb file and I’m trying to import a .js file to it by doing this at the start of the .html.erb:

<%= javascript_pack_tag 'script' %>

I already installed the webpacker in my rails project, the script.js is in ./javascript/packs directory and I still keep getting this error:

Webpacker can’t find script in
/home/mateus/Desktop/zNote/public/packs/manifest.json. Possible
causes:

  1. You want to set webpacker.yml value of compile to true for your environment unless you are using the webpack -w or the
    webpack-dev-server.
  2. webpack has not yet re-run to reflect updates.
  3. You have misconfigured Webpacker’s config/webpacker.yml file.
  4. Your webpack configuration is not creating a manifest. Your manifest contains: { }

My manifest file seems to be ok and also the webpacker.yml, I checked both but I still didn’t figure out how to solve this error. If I comment just this line <%= javascript_pack_tag 'script' %> the page loads without any errors and shows the HTML, but I need the javascript on it!