hotwired / turbo-rails

Use Turbo in your Ruby on Rails app
https://turbo.hotwired.dev
MIT License
2.07k stars 319 forks source link

Console Syntax Error #509

Open Jake839 opened 10 months ago

Jake839 commented 10 months ago

Hi, I'm getting the following error in my JS console: SyntaxError: Unexpected string literal "@hotwired/turbo-rails". import call expects one or two arguments.

Do you guys know how to fix the error? My Gemfile has: gem "turbo-rails"

And I have the following at the top of my application.js: // Configure your import map in config/importmap.rb. Read more: https://github.com/rails/importmap-rails import "@hotwired/turbo-rails" import "controllers"

// For chartkick.com import "chartkick" import "Chart.bundle"

//Globally disable Turbo for forms Turbo.setFormMode("off")

//= require jquery3 Added per ChatGPT 11/4/23



My app where this error is occurring is at https://github.com/Jake839/POTUS-Forum
marckohlbrugge commented 4 months ago

Did you solve this? I have the same issue after switching from esbuild to importmap

marckohlbrugge commented 1 month ago

I solved it by removing the explicit inclusion of application.js.

Before:

<head>
  <%= javascript_importmap_tags %>
  <%= javascript_include_tag "application" %>
</head>

After:

<head>
  <%= javascript_importmap_tags %>
</head>