2

I'm trying to move a rails 7 project from using esbuild to using importmaps and getting the following error:

// app/javascript/application.js
import '@hotwired/turbo-rails'; // <-- Uncaught SyntaxError: Cannot use import statement outside a module
import 'controllers';

I've run and rerun bundle exec rails importmap:install a bunch of times already and compared all relevant files that I know of with a project where importmaps work.

For obvious reasons, adding "type": "module", to package.json is not an option (I don't have a package.json).

Am I missing something?

1 Answer 1

4

Shamefully posting the solution in case anyone ever runs into the same problem:

We're using namespaces in the project and I forgot to include the javascript_importmap_tags tag in every namespaced layout file.

Sign up to request clarification or add additional context in comments.

1 Comment

Thank you for following up. You probably saved at least an hour of digging here.

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge you have read our privacy policy.

Start asking to get answers

Find the answer to your question by asking.

Ask question

Explore related questions

See similar questions with these tags.