3

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 }
Guillaume
  • 1,437
  • 2
  • 15
  • 17

1 Answers1

5

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/stimulus-autocomplete@3.0.2/src/autocomplete.min.js"
pierrea
  • 1,368
  • 14
  • 18