简体   繁体   中英

Application.js can't find @rails

I'm updating a fairly old project to rails 6, and adapt to current "rails ways". And I've just installed webpacker, but I've run into problem I can't seem to find a way to solve.

When running the project, I get this error: Uncaught Error: Cannot find module '@rails/ujs'

I've tried to reinstall rails-ujs through yarn, but to no effect.

Also I've tried to comment the line require("@rails/ujs").start() from my app/javascript/packs/application.js , and yet I got another error: Uncaught Error: Cannot find module '@rails/activestorage' .

Which leads me to believe that its the global @rails that is not being recognized, however I have no idea where is it set or how to do so.

My questions are: Can I set @rails myself?

Is there a way to re-generate it?

or

Is there another configuration I should fix?

It's not @rails which is missing, it's the ujs (and active storage) JavaScript packages which are missing.

Run yarn install To install them.

The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM