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

115
Vistas
Trouble importing Cytoscape and Dagre in Js

I'm trying to use Dagre with Cytoscape to visualize trees, but I'm having trouble when importing dagre and cytoscript in my javascript file. I keep getting an error "import declarations may appear only at a top level of a module".

My HTML:

<!DOCTYPE html>
<html lang="en">
    <head>
        <title>Document</title>
        <meta charset="UTF-8">
        <meta name="viewport" content="width=device-width, initial-scale=1">
        <link href="style.css" rel="stylesheet">
    </head>
    <body>
   
        <div id="cy"></div>

        <script src="tree.js"></script>

    </body>

</html>

My js file:

import cytoscape from 'cytoscape';
import dagre from 'cytoscape-dagre';

cytoscape.use( dagre );

When adding type="module" to my script tag in HTML I get a MIME type error (text/html).

I installed cytoscape-dagre via npm as per instructions on the Github repo: npm install cytoscape-dagre https://github.com/cytoscape/cytoscape.js-dagre

Appreciate any help.

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