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.