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.

    1
    • 1
      Thank you for following up. You probably saved at least an hour of digging here.CommentedJan 3, 2023 at 17:44

    Start asking to get answers

    Find the answer to your question by asking.

    Ask question

    Explore related questions

    See similar questions with these tags.