Reputation: 89
I pretty much copied the example and adjusted the database query. I dont understand why the driver is not recognized?
Version: Node: v11.13.0 neo4j-driver: "^1.7.5"
I get the Error:
var driver = neo4j.v1.driver(
^
TypeError: Cannot read property 'driver' of undefined
My Code:
var neo4j = require('neo4j-driver').v1;
var driver = neo4j.v1.driver(
'bolt://localhost:7687',
neo4j.auth.basic('neo4j', 'Neo4j')
)
var session = driver.session()
session
.run('MATCH (n:Person) return n', {
//nameParam: 'Alice'
})
.subscribe({
onNext: function(record) {
console.log(record.get('n'))
},
onCompleted: function() {
session.close()
},
onError: function(error) {
console.log(error)
}
})
Upvotes: 0
Views: 2371
Reputation: 12295
their docs seem screwed up, I had the exact same problem.
remove the v1
and it works. not sure if this defaults to a different version of the driver or something...
let config = require("./config")[env]
const uri = 'bolt://localhost:7687'
const neo4j = require('neo4j-driver');
const driver = neo4j.driver(uri, neo4j.auth.basic(config.username, config.password));
FWIW the way they define a config file is also broken. the node onboarding is pretty much a turn-off.
Upvotes: 0
Reputation: 67019
You probably meant to do this:
var neo4j = require('neo4j-driver').v1;
var driver = neo4j.driver(
...
Or, if for some reason you want to be able to explicitly specify the library version every time you use it, do this:
var neo4j = require('neo4j-driver');
var driver = neo4j.v1.driver(
...
Upvotes: 2