cancel
Showing results for 
Search instead for 
Did you mean: 

How to Connect to a Project with Node.js

eric-heim
Node

Hello,

I made a project database in Neo4j Desktop and ran some queries in Neo4j Browser. Now I'm trying to add a couple nodes via Node.js running a JavaScript file, but it's not working. Here's the code in the JavaScript file:

const neo4j = require('neo4j-driver');

const driver = neo4j.driver(

    'neo4j://localhost:7687',

    neo4j.auth.basic('neo4j', 'neo4j')

  );

  

const session = driver.session()

session.run('CREATE (n1:flashcard {English: "Hello"}), (n2:flashcard {English: "Goodbye"})');

session.close();

driver.close();

I'm not sure that I have the right URI in neo4j.driver(). Where am I supposed to get it? I ran :sysinfo in the browser and it listed the database name as neo4j and the address as localhost:7687, which is what I put.

7 REPLIES 7

david_allen
Neo4j
Neo4j

Your code looks basically OK, but it's hard to figure out what's going wrong without the error message.

Paste the full output of your program.

eric-heim
Node

There is no output. It just runs the program, and then I check the database in the browser, and see that two nodes haven't been added. What should I do?

By the way, it looks like the :server status command in the browser gives me the right URI.

tard_gabriel
Ninja
Ninja

How do you check the existing nodes in your Neo4j?

With MATCH (n) RETURN n in the Neo4j browser.

There must be something missing in the provided information, for now everything looks good.

arunkumar413
Node Clone

How to specify the local DBMS. Databases (system and neo4j) are created under DBMS on local desktop.

89099124147
Node Link

hi
did you manage to connect to neo4j desktop? do you have a solution?