TypeError: Cannot read property 'lookup' of undefined

992 views
Skip to first unread message

jcochran

unread,
Aug 12, 2012, 8:07:14 PM8/12/12
to der...@googlegroups.com
On my mac, the chat example is having trouble locating the 'racer-db-mongo' module.

derby.use(require 'racer-db-mongo') in server/index.coffee

There are no npm install build errors. I have mongo setup on my local machine. I can connect to "derby-chat" in the mongo REPL.

It is included in the package.json file.

{
  "name": "derby-chat-example",
  "description": "Demo chat application for Derby",
  "version": "0.0.0",
  "main": "./server.js",
  "dependencies": {
    "derby": "*",
    "express": "3.0.0beta4",
    "gzippo": ">=0.1.4",
    "racer-db-mongo": "*",
    "connect-mongo": ">=0.1.9"
  },
  "private": true,
  "devDependencies": {
    "coffee-script": ">=1.3.1"
  }
}

======= index.coffee ==========

http = require 'http'
path = require 'path'
express = require 'express'
gzippo = require 'gzippo'
derby = require 'derby'
chat = require '../chat'
serverError = require './serverError'


## SERVER CONFIGURATION ##

expressApp = express()
server = http.createServer expressApp
module.exports = server

derby.use(require 'racer-db-mongo')
store = derby.createStore
  db: {type: 'Mongo', uri: 'mongodb://localhost/derby-chat'}
  listen: server

======= stack trace ==========

$ node server.js
Error requiring server module from `/Users/jcochran/Projects/chat/src/server`

/Users/jcochran/Projects/chat/node_modules/derby/lib/derby.server.js:46
      throw e;
            ^
TypeError: Cannot read property 'lookup' of undefined
    at plugin (/Users/jcochran/Projects/chat/node_modules/racer-db-mongo/lib/index.js:18:27)
    at EventEmitter.module.exports.use (/Users/jcochran/Projects/chat/node_modules/derby/node_modules/racer/lib/plugin.js:39:7)
    at Object.<anonymous> (/Users/jcochran/Projects/chat/src/server/index.coffee:24:9)
    at Object.<anonymous> (/Users/jcochran/Projects/chat/src/server/index.coffee:53:4)
    at Module._compile (module.js:449:26)
    at Object.require.extensions..coffee (/Users/jcochran/Projects/chat/node_modules/coffee-script/lib/coffee-script/coffee-script.js:22:21)
    at Module.load (module.js:356:32)
    at Function.Module._load (module.js:312:12)
    at Module.require (module.js:362:17)
    at require (module.js:378:17)

Carl-Johan Blomqvist

unread,
Aug 13, 2012, 3:44:06 AM8/13/12
to der...@googlegroups.com
I believe you might not have racer-db-mongo installed. You'll have to run npm install inside of the chat folder to make it become installed (or ´npm install racer-db-mongo´ in derby-examples).

jcochran

unread,
Aug 13, 2012, 11:05:51 AM8/13/12
to der...@googlegroups.com

Yes racer-db-mongo is installed.

~ Jason

Krzysztof Baranowski

unread,
Aug 13, 2012, 3:20:58 PM8/13/12
to der...@googlegroups.com
racer-db-mongo 0.3.12-0 and the 0.3.12-1 are broken it seems. Use the previous version:

"racer-db-mongo": "0.3.11"

Chris

jcochran

unread,
Aug 13, 2012, 3:49:49 PM8/13/12
to der...@googlegroups.com
I have changed my package.json file:

{
  "name": "derby-chat-example",
  "description": "Demo chat application for Derby",
  "version": "0.0.0",
  "main": "./server.js",
  "dependencies": {
    "derby": "*",
    "express": "3.0.0beta4",
    "gzippo": ">=0.1.4",
    "racer-db-mongo": "0.3.11",
    "connect-mongo": ">=0.1.9"
  },
  "private": true,
  "devDependencies": {
    "coffee-script": ">=1.3.1"
  }
}

I deleted all the modules and ran npm install. No errors.

I now get the following error after node server.js:

Error requiring server module from `/Users/jcochran/Projects/chat/src/server`

/Users/jcochran/Projects/chat/node_modules/derby/lib/derby.server.js:46
      throw e;
            ^
TypeError: Cannot call method 'replace' of undefined
    at DbMongo.loadConf [as _loadConf] (/Users/jcochran/Projects/chat/node_modules/racer-db-mongo/lib/index.js:58:35)
    at new DbMongo (/Users/jcochran/Projects/chat/node_modules/racer-db-mongo/lib/index.js:34:21)
    at exports.createAdapter (/Users/jcochran/Projects/chat/node_modules/derby/node_modules/racer/lib/adapters/index.js:34:15)
    at new Store (/Users/jcochran/Projects/chat/node_modules/derby/node_modules/racer/lib/Store.js:60:23)
    at EventEmitter.racer.createStore (/Users/jcochran/Projects/chat/node_modules/derby/node_modules/racer/lib/racer.server.js:69:17)
    at Object.<anonymous> (/Users/jcochran/Projects/chat/src/server/index.coffee:26:17)
    at Object.<anonymous> (/Users/jcochran/Projects/chat/src/server/index.coffee:53:4)
    at Module._compile (module.js:449:26)
    at Object.require.extensions..coffee (/Users/jcochran/Projects/chat/node_modules/coffee-script/lib/coffee-script/coffee-script.js:22:21)

jcochran

unread,
Aug 13, 2012, 3:54:29 PM8/13/12
to der...@googlegroups.com
I forgot that I changed the path to the mongo db. I had it localhost. Now it is: localhost/derby-chat.

I now get the following error:

$ node server.js
   info  - socket.io started
Starting cluster with 1 workers in undefined mode
`kill -s SIGUSR2 8191` to force cluster reload

module.js:340
    throw err;
          ^
Error: Cannot find module '/Users/jcochran/Projects/chat/src/server'
    at Function.Module._resolveFilename (module.js:338:15)
    at Function.Module._load (module.js:280:25)
    at Module.require (module.js:362:17)
    at require (module.js:378:17)
    at Object.<anonymous> (/Users/jcochran/Projects/chat/node_modules/derby/node_modules/up/lib/worker.js:7:14)
    at Module._compile (module.js:449:26)
    at Object.Module._extensions..js (module.js:467:10)
    at Module.load (module.js:356:32)
    at Function.Module._load (module.js:312:12)
    at Module.runMain (module.js:492:10)
path.existsSync is now called `fs.existsSync`.

yuklai

unread,
Aug 17, 2012, 2:44:51 PM8/17/12
to der...@googlegroups.com
Are you still having this problem?
I was stuck at the issue above where changing racer-db-mongo's version resolved mine, thanks to your original question. So I was able to run the chat sample now. But I never ran into the last error you mentioned.
These are the steps I used:
  1. npm install derby-examples
  2. cd node_modules/derby-examples/[project]
  3. npm install
  4. make 
  5. node server.js

Tyler Renelle

unread,
Aug 17, 2012, 3:01:37 PM8/17/12
to der...@googlegroups.com

Krzysztof Baranowski

unread,
Aug 17, 2012, 4:07:27 PM8/17/12
to der...@googlegroups.com
jcochran and yuklai

Try pointing to chat/lib/server instead of chat/src/server. Compile (of module is in coffeescript) or move js into that directory first if necessary.

Chris

yuklai

unread,
Aug 17, 2012, 4:25:59 PM8/17/12
to der...@googlegroups.com
Just to clarify, I didn't hit the last issue jcochran last pointed out.
But you seem to be right, the server.js might have been mistakenly modified?

This is what I have:
require('derby').run(__dirname + '/lib/server', 3002);

When I changed lib to src it seem to repro the same error that jcochran posted.
Reply all
Reply to author
Forward
0 new messages