最新消息:Welcome to the puzzle paradise for programmers! Here, a well-designed puzzle awaits you. From code logic puzzles to algorithmic challenges, each level is closely centered on the programmer's expertise and skills. Whether you're a novice programmer or an experienced tech guru, you'll find your own challenges on this site. In the process of solving puzzles, you can not only exercise your thinking skills, but also deepen your understanding and application of programming knowledge. Come to start this puzzle journey full of wisdom and challenges, with many programmers to compete with each other and show your programming wisdom! Translated with DeepL.com (free version)

javascript - MongoDB - Error: Cannot find module '..buildReleasebson' - Stack Overflow

matteradmin4PV0评论

I tried to run a typescript example in the following way which caused following error:

$ mongod --dbpath /home/u/databases
$ npm install
$ tsc --sourcemap --module monjs app.ts
$ node app.js                             
{ [Error: Cannot find module '../build/Release/bson'] code: 'MODULE_NOT_FOUND' }
js-bson: Failed to load c++ bson extension, using pure JS version
========================================================================================
=  Please ensure that you set the default write concern for the database by setting    =
=   one of the options                                                                 =
=                                                                                      =
=     w: (value of > -1 or the string 'majority'), where < 1 means                     =
=        no write acknowledgement                                                       =
=     journal: true/false, wait for flush to journal before acknowledgement             =
=     fsync: true/false, wait for flush to file system before acknowledgement           =
=                                                                                      =
=  For backward patibility safe is still supported and                              =
=   allows values of [true | false | {j:true} | {w:n, wtimeout:n} | {fsync:true}]      =
=   the default value is false which means the driver receives does not                =
=   return the information of the success/error of the insert/update/remove            =
=                                                                                      =
=   ex: new Db(new Server('localhost', 27017), {safe:false})                           =
=                                                                                      =
=   +Command                           =
=                                                                                      =
=  The default of no acknowledgement will change in the very near future                =
=                                                                                      =
=  This message will disappear when the default safe is set on the driver Db           =
========================================================================================

/home/u/tmp/TypeScriptSamples/imageboard/app.js:9
app.configure(function () {
    ^
TypeError: Object function (req, res, next) {
    app.handle(req, res, next);
  } has no method 'configure'
    at Object.<anonymous> (/home/u/tmp/TypeScriptSamples/imageboard/app.js:9:5)
    at Module._pile (module.js:456:26)
    at Object.Module._extensions..js (module.js:474:10)
    at Module.load (module.js:356:32)
    at Function.Module._load (module.js:312:12)
    at Function.Module.runMain (module.js:497:10)
    at startup (node.js:119:16)
    at node.js:929:3

Furthermore, looking at db.ts I think http and url are missing in package.json file, am I right?

How is it possible to fix the above error with mongodb?

I tried to run a typescript example in the following way which caused following error:

$ mongod --dbpath /home/u/databases
$ npm install
$ tsc --sourcemap --module monjs app.ts
$ node app.js                             
{ [Error: Cannot find module '../build/Release/bson'] code: 'MODULE_NOT_FOUND' }
js-bson: Failed to load c++ bson extension, using pure JS version
========================================================================================
=  Please ensure that you set the default write concern for the database by setting    =
=   one of the options                                                                 =
=                                                                                      =
=     w: (value of > -1 or the string 'majority'), where < 1 means                     =
=        no write acknowledgement                                                       =
=     journal: true/false, wait for flush to journal before acknowledgement             =
=     fsync: true/false, wait for flush to file system before acknowledgement           =
=                                                                                      =
=  For backward patibility safe is still supported and                              =
=   allows values of [true | false | {j:true} | {w:n, wtimeout:n} | {fsync:true}]      =
=   the default value is false which means the driver receives does not                =
=   return the information of the success/error of the insert/update/remove            =
=                                                                                      =
=   ex: new Db(new Server('localhost', 27017), {safe:false})                           =
=                                                                                      =
=   http://www.mongodb/display/DOCS/getLastError+Command                           =
=                                                                                      =
=  The default of no acknowledgement will change in the very near future                =
=                                                                                      =
=  This message will disappear when the default safe is set on the driver Db           =
========================================================================================

/home/u/tmp/TypeScriptSamples/imageboard/app.js:9
app.configure(function () {
    ^
TypeError: Object function (req, res, next) {
    app.handle(req, res, next);
  } has no method 'configure'
    at Object.<anonymous> (/home/u/tmp/TypeScriptSamples/imageboard/app.js:9:5)
    at Module._pile (module.js:456:26)
    at Object.Module._extensions..js (module.js:474:10)
    at Module.load (module.js:356:32)
    at Function.Module._load (module.js:312:12)
    at Function.Module.runMain (module.js:497:10)
    at startup (node.js:119:16)
    at node.js:929:3

Furthermore, looking at db.ts I think http and url are missing in package.json file, am I right?

How is it possible to fix the above error with mongodb?

Share Improve this question edited Jan 25, 2015 at 14:11 user977828 asked Jan 25, 2015 at 12:58 user977828user977828 7,69917 gold badges70 silver badges121 bronze badges 1
  • 1 Did you try to execute npm update before doing it? – Ma'moon Al-Akash Commented Jan 25, 2015 at 14:20
Add a ment  | 

3 Answers 3

Reset to default 7

in Linux operating system first remove bson folder from node_modules and run this mand:

sudo apt-get install gcc make build-essential 

and then restart nodejs file such as index.js. Hope its helpful

I am using connect-mongo for sessions. I had the same problem and was because the version of connect-mongo generated an error with the version 4.0.x of mongoose. You could check each version of the dependencies you are using.

looking at db.ts I think http and url are missing in package.json file, am I right?

No. These modules are a part of core nodejs.

The source of the error is the package.json specifying minimum numbers without backward in patible version locks. https://github./Microsoft/TypeScriptSamples/blob/master/imageboard/package.json#L6 I would change '>=' to be harder versions e.g. 3.x

Post a comment

comment list (0)

  1. No comments so far