aseemk / node-neo4j-template

A template app for using Neo4j from Node.js.
http://node-neo4j-template.herokuapp.com/
216 stars 91 forks source link

`cypher` is not a function #21

Closed ianseyer closed 9 years ago

ianseyer commented 9 years ago

Hi there!

I'm following your template, however I seem to have hit a snag (two, actually, and I assume they are related):

  1. I get a db.createConstraint is not a function error. I commented it out, and was able to node app.js.

However, then, trying to access any data (specifically via REST) gives me

  1. cypher is not a function for db.cypher.

You can see it re-created in the REPL here:

> db
GraphDatabase {
  reviveJSON: [Function],
  url: 'http://neo4j:neo4j@localhost:7474',
  _request: 
   { get: [Function],
     post: [Function],
     put: [Function],
     del: [Function],
     head: [Function] },
  _root: null,
  _services: null }
> db.cypher
undefined
> db.cypher()
TypeError: db.cypher is not a function
    at repl:1:4
    at REPLServer.defaultEval (repl.js:164:27)
    at bound (domain.js:250:14)
    at REPLServer.runBound [as eval] (domain.js:263:12)
    at REPLServer.<anonymous> (repl.js:392:12)
    at emitOne (events.js:82:20)
    at REPLServer.emit (events.js:169:7)
    at REPLServer.Interface._onLine (readline.js:210:10)
    at REPLServer.Interface._line (readline.js:546:8)
    at REPLServer.Interface._ttyWrite (readline.js:823:14)
aseemk commented 9 years ago

Hi @ianseyer, it looks like you have v1 of node-neo4j, when you want v2.

The template app's package.json specifies v2:

https://github.com/aseemk/node-neo4j-template/blob/47528b307b815ac432bcfb865acfa86b6159e6c9/package.json#L10

So maybe you manually installed node-neo4j at some point?

No harm — you can simply npm uninstall neo4j then npm install, and that should do the trick (assuming your package.json matches what I linked above).

Hope this helps!

ianseyer commented 9 years ago

D'oh!

thank you :)

aseemk commented 9 years ago

No prob, glad that helped. =)

jaitkin commented 9 years ago

Hello, I seem to be getting the same error, although I believe I have version 2.14.7 (this is what is received when I use "npm node-neo4j --version")

Below is the exact error. Thank you in advance!

db.cypher({
   ^

TypeError: db.cypher is not a function
    at Object.<anonymous> ([path]/[file].js:9:4)
    at Module._compile (module.js:435:26)
    at Object.Module._extensions..js (module.js:442:10)
    at Module.load (module.js:356:32)
    at Function.Module._load (module.js:311:12)
    at Function.Module.runMain (module.js:467:10)
    at startup (node.js:134:18)
    at node.js:961:3
aseemk commented 9 years ago

Can you console.log(db)?

aseemk commented 9 years ago

Oh, node-neo4j isn't this package. This package is just neo4j.

dannyid commented 8 years ago

Hi, I'm having a similar issue to @jaitkin.

Install and init:

var neo4j = require('neo4j');
var db = new neo4j.GraphDatabase('http://user:pass@localhost:7474');

npm neo4j --version shows: 2.14.4

console.log(db) shows:

GraphDatabase {
  reviveJSON: [Function],
  url: 'http://user:pass@localhost:7474',
  _request: 
   { get: [Function],
     post: [Function],
     put: [Function],
     del: [Function],
     head: [Function] },
  _root: null,
  _services: null }
dannyid commented 8 years ago

Nevermind, even though npm neo4j --version shows: 2.14.4, my package.json had version ^1.1.11. Update manually to 2.0.0-RC2 fixed the problem.

JohnLonginotto commented 8 years ago

Eek, I had the exact same problem. "npm install neo4j" was installing 1.1.11, even though --version was reporting 3.3.12.

Manually upgraded using:

    npm uninstall neo4j
    npm install neo4j@2.0.0-RC1

Im running Ubuntu Linux via an amazon AWS instance. Installed the system fresh 2 hours ago, and everything was up to date.

f1nnix commented 8 years ago

@JohnLonginotto +1, it worked! Saved me a lot of time