Hi,
anyone knows how to solve the problem of Module not found: Error: Can't resolve '@rails/ujs' in Rails6.

I also tried to install in npm the : npm i @rails/ujs but still the same error that can't find ujs.
If you need more info, let me know.
Thanks in advance.
In order to help debug, could you please post as much as you can of:
./package.json./config/webpack/environment.js./config/webpacker.yml./app/javascript/packs/application.js 鈥攖o a single https://gist.github.com. Please tag me via @jakeNiemiec in a comment and I鈥檒l try to troubleshoot any problems directly in the gist.
Hi @jakeNiemiec I already resolved the problem. via adding : Rails: ['@rails/ujs'] in environment.js
Thanks
Cheers!
yarn add @rails/ujs
@lrjbrual I have the same issue and this is working
environment.plugins.prepend('Provide',
new webpack.ProvidePlugin({
$: 'jquery',
jQuery: 'jquery'
Rails: '@rails/ujs'
})
)
But I wonder why this way below is not working:
import Rails from "@rails/ujs"
Rails.start()
why this way below is not working
In what way does it not work? If you use it globally (like in a
Most helpful comment
Hi @jakeNiemiec I already resolved the problem. via adding :
Rails: ['@rails/ujs']in environment.jsThanks
Cheers!