0
votes

I'v seen every other questions, but it seem that this case is different. Actually, I'm trying to follow this video that is implementring the example https://neo4j.com/developer/javascript/

My code is in 'app.js' is:

var express = require('express');
var path = require('path');
var logger = require('morgan');
var bodyParser = require('body-parser');
var neo4j = require('neo4j-driver').v1;

var app = express();

// View Engine
app.set('views', path.join(__dirname, 'views'));
app.set('view engine', "ejs");

app.use(logger('dev'));
app.use(bodyParser.json());
app.use(bodyParser.urlencoded({ extended: false}));
app.use(express.static(path.join(__dirname, 'public')));

var driver = neo4j.driver(
        'bolt://localhost:7687', 
        neo4j.auth.basic('Graph', 'password')
    );
var session = driver.session();

app.get('/', function(req, res){
    session
        .run('MATCH(n:Movie) RETURN n LIMIT 25')
        .then(function(result){
            result.records,forEach(function(record){
                console.log(record);
            })
        })
        .catch(function(){
            console.log(err);
        });
    res.send('It works!!!');
});


app.listen(3000);
console.log('Server Started on Port 3000');

module.exports = app;

With the error is:

var driver = neo4j.driver(
                   ^

TypeError: Cannot read property 'driver' of undefined
    at Object.<anonymous> (C:\Users\rkoro\Documents\_RoKo\programm_2020-01-27\app.js:18:20)
    at Module._compile (internal/modules/cjs/loader.js:955:30)
    at Object.Module._extensions..js (internal/modules/cjs/loader.js:991:10)
    at Module.load (internal/modules/cjs/loader.js:811:32)
    at Function.Module._load (internal/modules/cjs/loader.js:723:14)
    at Function.Module.runMain (internal/modules/cjs/loader.js:1043:10)
    at internal/main/run_main_module.js:17:11
1

1 Answers

0
votes

The latest version of driver has been moved from .v1 namespace to neo4j namespace. See the readme here - https://www.npmjs.com/package/neo4j-driver

Basically remove .v1 and it should work. like this var neo4j = require('neo4j-driver');