afcapel / stimulus-autocomplete

Stimulus autocomplete component
MIT License
478 stars 61 forks source link

Failed to resolve module specifier "stimulus-autocomplete" #106

Closed GuillaumeOcculy closed 2 years ago

GuillaumeOcculy commented 2 years ago

Ruby 3.0.3 Rails 7.0.0.alpha2

Hello

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 }
pprencel commented 2 years ago

@GuillaumeOcculy Did you add package via importmap command? I had same isssue and I solved it by changing package path in config/importmap.rb

# pin "stimulus-autocomplete", to: "https://ga.jspm.io/npm:stimulus-autocomplete@3.0.2/src/autocomplete.js"
pin "stimulus-autocomplete", to: "https://cdn.jsdelivr.net/npm/stimulus-autocomplete@3.0.2/src/autocomplete.min.js" 
afcapel commented 2 years ago

That's correct, I've updated the documentation in 747236e5e10622263196ebee10f035528ce54481.

GuillaumeOcculy commented 2 years ago

Thanks @pprencel