question-mark
Stuck on an issue?

Lightrun Answers was designed to reduce the constant googling that comes with debugging 3rd party libraries. It collects links to all the places you might be looking at while hunting down a tough bug.

And, if you’re still stuck at the end, we’re happy to hop on a call to see how we can help out.

Getting Uncaught Error: Cannot find module 'controllers'

See original GitHub issue

Hello 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:closed
  • Created 3 years ago
  • Comments:9 (3 by maintainers)

github_iconTop GitHub Comments

1reaction
kuei0221commented, Jan 24, 2021

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 😄

0reactions
noctivityinccommented, Feb 3, 2021

The README needs to be updated to reflect the new steps

Read more comments on GitHub >

github_iconTop 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 >

github_iconTop Related Medium Post

No results found

github_iconTop Related StackOverflow Question

No results found

github_iconTroubleshoot Live Code

Lightrun enables developers to add logs, metrics and snapshots to live code - no restarts or redeploys required.
Start Free

github_iconTop Related Reddit Thread

No results found

github_iconTop Related Hackernoon Post

No results found

github_iconTop Related Tweet

No results found

github_iconTop Related Dev.to Post

No results found

github_iconTop Related Hashnode Post

No results found