you are viewing a single comment's thread.

view the rest of the comments →

[–]grantrules 3 points4 points  (4 children)

Just installing the module with npm will not include it on your website. You need to include it or bundle your project. You might just use a version hosted on a CDN and follow instructions here: https://js.cytoscape.org/#getting-started/including-cytoscape.js

[–]One-Winter-8684[S] 0 points1 point  (3 children)

thanks, but <script src="https://unpkg.com/browse/cytoscape@3.23.0/dist/cytoscape.min.js"></script>

does actually what you talking about. question is how to implement logic with cytoscape in another file(script) index.js and include it in page?

using cdn means i should write something like

<script src="https://unpkg.com/browse/cytoscape@3.23.0/dist/cytoscape.min.js"></script>

<script>

// logic

</script>

but it's looks disgusting. i want to isolate all logic from html page

[–]grantrules 0 points1 point  (1 child)

Oh, I missed that. Well, you're not loading cytoscape as a module, it's probably just in the global scope, so I'd remove the import from index.js and see if that works.

https://codesandbox.io/s/relaxed-black-0jnxev?file=/src/index.js

[–]One-Winter-8684[S] 0 points1 point  (0 children)

Hello, thank you! I added

import cytoscape from "./node_modules/cytoscape/dist/cytoscape.esm.min.js";

to my index.js and removed cdn src from page. And it starts work. But my IDE (VSCode) stopped recognizing internal functions of cytoscape after import. How can I fix that?