'ModuleNotFoundError when deploying Rails to Heroku

While trying to push the app, it keeps returning "Precompiling assets failed.". The logs mention that the error would be:

> ModuleNotFoundError: Module not found: Error: Can't resolve
> '@rails/ujs' in '/tmp/build_23159804/app/javascript/packs'

Here's the file that contains it:

import Rails from "@rails/ujs"
import Turbolinks from "turbolinks"
import * as ActiveStorage from "@rails/activestorage"
import "channels"

Rails.start()
Turbolinks.start()
ActiveStorage.start()

import 'bootstrap/dist/js/bootstrap'
import "bootstrap/dist/css/bootstrap";
import "../stylesheets/application"
require("stylesheets/application.scss")

I do have the 'rails-ujs' gem installed. What could be causing this?



Sources

This article follows the attribution requirements of Stack Overflow and is licensed under CC BY-SA 3.0.

Source: Stack Overflow

Solution Source