Empresas
Empleos
  • Sobre nosotros
  • Soluciones
    • Publicación de vacantes
      Publica tu vacante y recibe candidatos calificados en 48h.
    • Evaluación de candidatos
      500+ pruebas técnicas y psicológicas, más anti-fraude.
    • Headhunting
      Búsqueda ejecutiva a la medida de principio a fin.
    • Nómina + EOR
      Dispersión de nómina y EOR en más de 15 países de LATAM.
  • Precios
  • Empleos

0

124
Vistas
Reactjs test on rails app works locally but displays error in heroku version

Sorry for the lack of formatting, I'm new here. I've recently started making a switch from jQuery to React in my app. I removed all the little js code, installed turborails and importmap, planning to use a mix of html and rails for my pages. I managed to get the app working locally and all, but in the heroku build, the application.js doesn't import the dependencies, displaying:

uncaught syntaxerror: import declarations may only appear at top level of a module

when I check the console in developer tools, at this

I'm using importmap and including the app.js through a javascript_include_tag This is how my application.jss looks. The error points to the hotwired line

import "@hotwired/turbo-rails"
import "./components/seconds.jsx"

How can I make it work in heroku?

EDIT: Through some messy trial and error, I figured out a solution. So it seems that browsers don't support import without being modules? So my solution was to build the application.js and replace my previous application.js with the built version. It works both locally and on heroku, though a minor nuisance is that I'll have to npm build every time I alter something in my javascript and need to push it, but it's doable.

about 4 years ago · Juan Pablo Isaza
Responde la pregunta
Encuentra empleos remotos

¡Descubre la nueva forma de encontrar empleo!

Top de empleos
Top categorías de empleo
Empresas
Publicar vacante Precios Comercial
Legal
Términos y condiciones Política de privacidad
© 2026 PeakU Inc. All Rights Reserved.
Andres GPT
Recomiéndame algunas ofertas
Necesito ayuda