jonas PRO
Joined 7/29/2020
jonas PRO said almost 3 years ago on Autocomplete with StimulusJS :
I have a legacy project in Rails 6.1 where I use assets pipeline and yarn. Tried webpacker but got in to trouble with a lot of old jquery which I am trying to replace with new stimulus code. Hence the need for stimulus-autocomplete.

I can't get the stimulus-autocomplete to load, I get:
Failed to autoload controller: autocomplete - Error: Unable to resolve specifier 'autocomplete_controller' from http://localhost:3000/dev-assets/stimulus/loaders/autoloader.debug.js

I have
Rails.application.config.assets.paths << Rails.root.join('node_modules')
in assets.rb

What needs to be done in order to import controllers from node_modules into stimulus using assets_pipeline?


jonas PRO said almost 3 years ago on Autocomplete with StimulusJS :
Thanks,

Stimulus is added via gem 'stimulus-rails', works fine. The index.js looks just like in the episode.
Had forgotten to change the defaults to 6.1, it was 6.0, but it made no difference.

Is sprockets supposed to compile the node_modules to dev-assets or how is it supposed to work?