koa-rest mongodb 报错

[code]WangWilliamdeMacBook-Pro-3:koa-rest wangwilliam$ npm test

> koa-rest@1.0.0 test /Users/wangwilliam/projects/others/koa-rest
> mocha --harmony

{ Error: Cannot find module ‘…/build/Release/bson’
at Function.Module._resolveFilename (module.js:440:15)
at Function.Module._load (module.js:388:25)
at Module.require (module.js:468:17)
at require (internal/module.js:20:19)
at Object.<anonymous> (/Users/wangwilliam/projects/others/koa-rest/node_modules/bson/ext/index.js:15:10)
at Module._compile (module.js:541:32)
at Object.Module._extensions…js (module.js:550:10)
at Module.load (module.js:458:32)
at tryModuleLoad (module.js:417:12)
at Function.Module._load (module.js:409:3)
at Module.require (module.js:468:17)
at require (internal/module.js:20:19)
at Object.<anonymous> (/Users/wangwilliam/projects/others/koa-rest/node_modules/bson/lib/bson/index.js:3:24)
at Module._compile (module.js:541:32)
at Object.Module._extensions…js (module.js:550:10)
at Module.load (module.js:458:32)
at tryModuleLoad (module.js:417:12)
at Function.Module._load (module.js:409:3)
at Module.require (module.js:468:17)
at require (internal/module.js:20:19)
at Object.<anonymous> (/Users/wangwilliam/projects/others/koa-rest/node_modules/mongodb/lib/mongodb/index.js:2:22)
at Module._compile (module.js:541:32)
at Object.Module._extensions…js (module.js:550:10)
at Module.load (module.js:458:32)
at tryModuleLoad (module.js:417:12)
at Function.Module._load (module.js:409:3)
at Module.require (module.js:468:17)
at require (internal/module.js:20:19)
at Object.<anonymous> (/Users/wangwilliam/projects/others/koa-rest/node_modules/monk/node_modules/mongoskin/lib/index.js:14:13)
at Module._compile (module.js:541:32)
at Object.Module._extensions…js (module.js:550:10)
at Module.load (module.js:458:32)
at tryModuleLoad (module.js:417:12)
at Function.Module._load (module.js:409:3)
at Module.require (module.js:468:17)
at require (internal/module.js:20:19)
at Object.<anonymous> (/Users/wangwilliam/projects/others/koa-rest/node_modules/monk/node_modules/mongoskin/index.js:1:132)
at Module._compile (module.js:541:32)
at Object.Module._extensions…js (module.js:550:10)
at Module.load (module.js:458:32)
at tryModuleLoad (module.js:417:12)
at Function.Module._load (module.js:409:3)
at Module.require (module.js:468:17)
at require (internal/module.js:20:19)
at Object.<anonymous> (/Users/wangwilliam/projects/others/koa-rest/node_modules/monk/lib/manager.js:5:17)
at Module._compile (module.js:541:32)
at Object.Module._extensions…js (module.js:550:10)
at Module.load (module.js:458:32)
at tryModuleLoad (module.js:417:12)
at Function.Module._load (module.js:409:3)
at Module.require (module.js:468:17)
at require (internal/module.js:20:19)
at Object.<anonymous> (/Users/wangwilliam/projects/others/koa-rest/node_modules/monk/lib/monk.js:6:28)
at Module._compile (module.js:541:32)
at Object.Module._extensions…js (module.js:550:10)
at Module.load (module.js:458:32)
at tryModuleLoad (module.js:417:12)
at Function.Module._load (module.js:409:3)
at Module.require (module.js:468:17)
at require (internal/module.js:20:19)
at Object.<anonymous> (/Users/wangwilliam/projects/others/koa-rest/controllers/books.js:4:12)
at Module._compile (module.js:541:32)
at Object.Module._extensions…js (module.js:550:10)
at Module.load (module.js:458:32)
at tryModuleLoad (module.js:417:12)
at Function.Module._load (module.js:409:3)
at Module.require (module.js:468:17)
at require (internal/module.js:20:19)
at Object.<anonymous> (/Users/wangwilliam/projects/others/koa-rest/app.js:2:13)
at Module._compile (module.js:541:32)
at Object.Module._extensions…js (module.js:550:10)
at Module.load (module.js:458:32)
at tryModuleLoad (module.js:417:12)
at Function.Module._load (module.js:409:3)
at Module.require (module.js:468:17)
at require (internal/module.js:20:19)
at Object.<anonymous> (/Users/wangwilliam/projects/others/koa-rest/test/routeSpec.js:4:11)
at Module._compile (module.js:541:32)
at Object.Module._extensions…js (module.js:550:10)
at Module.load (module.js:458:32)
at tryModuleLoad (module.js:417:12)
at Function.Module._load (module.js:409:3)
at Module.require (module.js:468:17)
at require (internal/module.js:20:19)
at /Users/wangwilliam/projects/others/koa-rest/node_modules/mocha/lib/mocha.js:220:27
at Array.forEach (native)
at Mocha.loadFiles (/Users/wangwilliam/projects/others/koa-rest/node_modules/mocha/lib/mocha.js:217:14)
at Mocha.run (/Users/wangwilliam/projects/others/koa-rest/node_modules/mocha/lib/mocha.js:469:10)
at Object.<anonymous> (/Users/wangwilliam/projects/others/koa-rest/node_modules/mocha/bin/_mocha:404:18)
at Module._compile (module.js:541:32)
at Object.Module._extensions…js (module.js:550:10)
at Module.load (module.js:458:32)
at tryModuleLoad (module.js:417:12)
at Function.Module._load (module.js:409:3)
at Function.Module.runMain (module.js:575:10)
at startup (node.js:160:18)
at node.js:456:3 code: ‘MODULE_NOT_FOUND’ }
js-bson: Failed to load c++ bson extension, using pure JS version[/code]
解决方案:

[quote]
/Users/wangwilliam/projects/others/koa-rest/node_modules/bson/ext/index.js
[/quote]

将[code] // Load the precompiled win32 binary
if(process.platform == “win32” && process.arch == “x64”) {
bson = require(’./win32/x64/bson’);
} else if(process.platform == “win32” && process.arch == “ia32”) {
bson = require(’./win32/ia32/bson’);
} else {
bson = require(’…/build/Release/bson’);
} [/code]修改为:
[code] // Load the precompiled win32 binary
if(process.platform == “win32” && process.arch == “x64”) {
bson = require(’./win32/x64/bson’);
} else if(process.platform == “win32” && process.arch == “ia32”) {
bson = require(’./win32/ia32/bson’);
} else {
bson = require(‘bson’);
} [/code]