stimulus-components icon indicating copy to clipboard operation
stimulus-components copied to clipboard

Failed to resolve module specifier Rails 7.0 (All components)

Open sergitejada opened this issue 3 years ago • 2 comments

I am trying to use the components following the documentation

  1. I install the package of the component I want with yarn.
  2. In my app/javascript/controllers/index.js file I add the component as described in the documentation.

image

Error displayed by the browser Uncaught TypeError: Failed to resolve module specifier "stimulus-autocomplete". Relative references must start with either "/", "./", or "../".

I have found people with my same problem that solved it with a package call to a yarn cdn, I think it makes no sense to call a cnd with the code when the code is in local.

Error-1 Error-2

ruby "2.7.0" rails "7.0.2"

sergitejada avatar May 17 '22 16:05 sergitejada

Did you ever solve this? I'm trying to migrate my rails 7 app from sprockets to importmaps and am getting a similar error, I believe rails isn't properly using the importmap for some reason to figure out where to load the packages from, but can't figure out where to look next.

inspire22 avatar Oct 13 '22 19:10 inspire22

@inspire22 You can try this way

  1. Import stimulus-dropdown
./bin/importmap pin stimulus-dropdown
  1. Append the following lines to your controller
import { application } from "controllers/application"; # Remove this line if you are appending to application.js

import ContentLoader from 'stimulus-content-loader'

application.register('content-loader', ContentLoader)

hieunguyentrung avatar Oct 26 '23 04:10 hieunguyentrung

Same as https://github.com/stimulus-components/stimulus-components/issues/81#issuecomment-2027343664

guillaumebriday avatar Mar 29 '24 14:03 guillaumebriday