Business
Jobs
  • About Us
  • Solutions
    • Job Postings
      Post your job and receive qualified candidates in 48h.
    • Candidate Assessments
      500+ technical and psychological tests, plus anti-fraud.
    • Headhunting
      Tailor-made executive search from start to finish.
    • Payroll + EOR
      Payroll dispersal and EOR across 15+ LATAM countries.
  • Pricing
  • Jobs

0

116
Views
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
Answer question
Find remote jobs

Discover the new way to find a job!

Top jobs
Top job categories
Business
Post vacancy Pricing Sales
Legal
Terms and conditions Privacy policy
© 2026 PeakU Inc. All Rights Reserved.
Andres GPT
Show me some job opportunities
There's an error!