EDIT: file:///C:/Users/myusername/node_modules/vis-network/standalone/umd/vis-network.min.js is the syntax it wants for local files! Someone suggested it here: What is the right way to write my script 'src' url for a local development environment?
now the question is: why does it need this when running javascript inside html?
The following code is copied directly from https://www.npmjs.com/package/vis-network with some tiny things added of mine to play with it
<!DOCTYPE html>
<html lang="en">
<head>
<title>Network</title>
<script
type="text/javascript"
src="https://unpkg.com/vis-network/standalone/umd/vis-network.min.js"
></script>
<style type="text/css">
#mynetwork {
width: 600px;
height: 400px;
border: 1px solid lightgray;
}
</style>
</head>
<body>
<div id="mynetwork"></div>
<script type="text/javascript">
// create an array with nodes
var nodes = new vis.DataSet([
{ id: 1, label: "Node 1" },
{ id: 2, label: "Node 2" },
{ id: 3, label: "Node 3" },
{ id: 4, label: "Node 4" },
{ id: 5, label: "Node 5" },
]);
// create an array with edges
var edges = new vis.DataSet([
{ from: 1, to: 3 },
{ from: 1, to: 2 },
{ from: 2, to: 4 },
{ from: 2, to: 5 },
{ from: 3, to: 3 },
]);
nodes.add({id: 6, label: "egg"}) //works!
// create a network
var container = document.getElementById("mynetwork");
var data = {
nodes: nodes,
edges: edges,
};
var options = {};
var network = new vis.Network(container, data, options);
</script>
</body>
</html>
This runs fine and opens up in firefox and has nodes to play with. It seems to me with this you don't need node.js installed. Just copy it into a file. Name as something.html and open it in a web browser.
Now, when I try to replace the <script src = "">
tag with what I think is the location of the local file, it doesn't work.
I've tried slight variations of this:
<script
type="text/javascript"
src="C:\\Users\\myusername\\node_modules\\vis-network\\standalone\\umd\\vis-network.min.js"
></script>
I have no idea why it wouldn't work and don't really know how to start debugging it. I am a complete hack of a programmer.
Naively, it seems like it's just referencing a different location for the same file. Maybe my file is broken some how. In which case, I should be able to download the file from the first SRC tag in the example and just load that locally, but it also doesn't work. It seems like it's just something about my src tag.
Thank you for your time.