admin管理员组

文章数量:1401158

I am trying to create a connection between my html embedded javascript and my neo4j database by running the index.html in Chrome. I have reduced the source of the problem to 'neo4j' not being recognised. So the error thrown will be of the type:

Cannot read property ['driver'/'basic'/etc...] of undefined.

In this case I have assumed that 'undefined' is referring to 'neo4j', which would mean that I am not implementing 'neo4j-web.min.js' correctly.

The below block of code is extracted from my index.html and has been taken from:

<script src="node_modules/neo4j-driver/lib/browser/neo4j-web.min.js"></script>
<script type="text/javascript" charset="utf-8">
  var driver = neo4j.driver("bolt://localhost:7474", neo4j.auth.basic(neo4j, 
  neo4j));
</script>

Given that the issue seems very localised to this code, I spared everyone the rest of the document. If further context is missing, I'd be happy to provide it.

I am trying to create a connection between my html embedded javascript and my neo4j database by running the index.html in Chrome. I have reduced the source of the problem to 'neo4j' not being recognised. So the error thrown will be of the type:

Cannot read property ['driver'/'basic'/etc...] of undefined.

In this case I have assumed that 'undefined' is referring to 'neo4j', which would mean that I am not implementing 'neo4j-web.min.js' correctly.

The below block of code is extracted from my index.html and has been taken from: https://www.npmjs./package/neo4j-driver

<script src="node_modules/neo4j-driver/lib/browser/neo4j-web.min.js"></script>
<script type="text/javascript" charset="utf-8">
  var driver = neo4j.driver("bolt://localhost:7474", neo4j.auth.basic(neo4j, 
  neo4j));
</script>

Given that the issue seems very localised to this code, I spared everyone the rest of the document. If further context is missing, I'd be happy to provide it.

Share Improve this question asked May 26, 2017 at 15:36 Christopher MillsChristopher Mills 76013 silver badges29 bronze badges 2
  • Have you installed the neo4j-driver module using npm? – varbrad Commented May 26, 2017 at 15:38
  • Yes. Just double checked anyway. Version 3.10.10 – Christopher Mills Commented May 26, 2017 at 15:43
Add a ment  | 

2 Answers 2

Reset to default 7

The neo4j-driver module uses an odd system whereby you have to specify which version of the API you want to use.

<script src="node_modules/neo4j-driver/lib/browser/neo4j-web.min.js"></script>
<script type="text/javascript" charset="utf-8">
  neo4j = neo4j.v1
  var driver = neo4j.driver("bolt://localhost:7474", neo4j.auth.basic(neo4j, 
  neo4j));
</script>

I agree with @varbrad My 2cts: check the servername You are using the alias localhost

本文标签: htmlUnable to establish a neo4jbolt driver connection in javascriptStack Overflow