Getting Uncaught Error: Cannot find module 'controllers'
See original GitHub issueHello there, I have just installed Hotwire gem and everything is working fine with turbo, but I could not manage to make stimulus work.
I am getting: Uncaught Error: Cannot find module 'controllers'
I am using: Rails 6.0.3.4 Ruby 2.7.1 Stimulus-rails 0.2.2
This is my application.js
// This file is automatically compiled by Webpack, along with any other files
// present in this directory. You're encouraged to place your actual application logic in
// a relevant structure within app/javascript and only use these pack files to reference
// that code so it'll be compiled.
require("@rails/ujs").start()
require("@rails/activestorage").start()
require("channels")
// Uncomment to copy all static images under ../images to the output folder and reference
// them with the image_pack_tag helper in views (e.g <%= image_pack_tag 'rails.png' %>)
// or the `imagePath` JavaScript helper below.
//
// const images = require.context('../images', true)
// const imagePath = (name) => images(name, true)
import "controllers"
require("trix")
require("@rails/actiontext")
I have tried running rails stimulus:install
The error I get is:
Uncaught Error: Cannot find module 'controllers'
at webpackMissingModule
Issue Analytics
- State:
- Created 3 years ago
- Comments:9 (3 by maintainers)
Top Results From Across the Web
NodeJS cannot find custom module - Stack Overflow
In your case it fails to find a file named controller.js so it assumes it's a directory and then searches for index.js specifically....
Read more >cannot find module [Node npm Error Solved] - freeCodeCamp
When you get the “cannot find module” error, or “module not found”, it means you've not installed the package you're trying to use....
Read more >How to solve "Error: Cannot find module '*.js'" with Node.js
You need to double check you are running the correct file from the correct directory. Here are some steps to diagnose. General tips....
Read more >Error: Cannot find module 'express' - YouTube
Error : Cannot find module 'express' Error : Cannot find module 'cors' Error : Cannot find module 'body-parser' Error : Cannot find module...
Read more >Fix Global Installs Not Working | "Cannot find module" error FIX
Getting " Cannot find module " after installing something globally (with -g)? Well, this video shows you how to fix global package/module ...
Read more >Top Related Medium Post
No results found
Top Related StackOverflow Question
No results found
Troubleshoot Live Code
Lightrun enables developers to add logs, metrics and snapshots to live code - no restarts or redeploys required.
Start FreeTop Related Reddit Thread
No results found
Top Related Hackernoon Post
No results found
Top Related Tweet
No results found
Top Related Dev.to Post
No results found
Top Related Hashnode Post
No results found
Top GitHub Comments
Cool, that is what exactly we need. I found this file here https://github.com/rails/webpacker/blob/v4.0.0/lib/install/examples/stimulus/controllers/index.js, we can just place it in the controller directory and
stimulus:install:webpacker
will handle it for us. I will make a PR for this 😄The README needs to be updated to reflect the new steps