Cannot call method 'toHexString' of undefined

638 views
Skip to first unread message

Stella Laurenzo

unread,
Feb 1, 2011, 3:56:42 PM2/1/11
to Mongoose Node.JS ORM
Hi, I just installed mongoose with npm and just to verify things, I
did a "require('mongoose')" from the node shell and got this
exception:

> require('mongoose')
TypeError: Cannot call method 'toHexString' of undefined
at Function.toString (/home/stella/local/nodejs/lib/node/.npm/
mongoose/1.0.0/package/lib/mongoose/drivers/node-mongodb-native/
objectid.js:34:14)

It threw me for a second until I realized that this was just an
artifact of the REPL of the node shell trying to print the result of
require(...) and hitting on the export for objectid.js. Since the
objectid module declares a toString(oid), the node shell was trying to
invoke this with no arguments to get a string representation. This
throws an error.

This probably wouldn't happen in any real code, but it seems like a
bad idea to be defining toString(oid) in this fashion. I'm not sure
what the impact to changing it would be though.

- stella

Guillermo Rauch

unread,
Feb 1, 2011, 4:59:56 PM2/1/11
to mongoo...@googlegroups.com
Good call, I ran into this too and was pretty puzzled.

--
Guillermo Rauch
http://devthought.com
Reply all
Reply to author
Forward
0 new messages