Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

Failed to resolve module specifier "stimulus-autocomplete"

Ruby 3.0.3 Rails 7.0.0.alpha2

After following the instructions to install and usage, I launch the server and I received this error: Uncaught TypeError: Failed to resolve module specifier "stimulus-autocomplete". Relative references must start with either "/", "./", or "../".

# app/javascript/controllers/application.js
import { Application } from "@hotwired/stimulus"
import { Autocomplete } from "stimulus-autocomplete"
# and tried import { Autocomplete } from 'stimulus-autocomplete/src/autocomplete'

const application = Application.start()
application.register('autocomplete', Autocomplete)

// Configure Stimulus development experience
application.debug = false
window.Stimulus   = application

export { application }
like image 537
Guillaume Avatar asked Oct 28 '25 08:10

Guillaume


1 Answers

If you use import maps, did you add "stimulus-autocomplete" in your config/importmap.rb so the lib can be imported?

pin "stimulus-autocomplete", to: "https://cdn.jsdelivr.net/npm/[email protected]/src/autocomplete.min.js"
like image 71
pierrea Avatar answered Oct 29 '25 22:10

pierrea