简体   繁体   English

MongoDB - 错误:无法找到模块'../build/Release/bson'

[英]MongoDB - Error: Cannot find module '../build/Release/bson'

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 commonjs 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 compatibility 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.org/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._compile (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? 此外,看看db.ts我认为package.json文件中缺少httpurl ,对不对?

How is it possible to fix the above error with mongodb? 如何用mongodb修复上述错误?

in Linux operating system first remove bson folder from node_modules and run this command: 在Linux操作系统中,首先从node_modules删除bson文件夹并运行以下命令:

sudo apt-get install gcc make build-essential 

and then restart nodejs file such as index.js . 然后重新启动nodejs文件,例如index.js Hope its helpful 希望它有所帮助

I am using connect-mongo for sessions. 我正在使用connect-mongo进行会话。 I had the same problem and was because the version of connect-mongo generated an error with the version 4.0.x of mongoose. 我有同样的问题,因为connect-mongo的版本与mongoose的4.0.x版本生成了错误。 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? 看看db.ts我认为package.json文件中缺少http和url,对不对?

No. These modules are a part of core nodejs. 不。这些模块是核心nodejs的一部分。

The source of the error is the package.json specifying minimum numbers without backward in compatible version locks. 错误的来源是package.json,它指定了兼容版本锁中没有向后的最小数字。 https://github.com/Microsoft/TypeScriptSamples/blob/master/imageboard/package.json#L6 I would change '>=' to be harder versions eg 3.x https://github.com/Microsoft/TypeScriptSamples/blob/master/imageboard/package.json#L6我会将'> ='更改为更难的版本,例如3.x

暂无
暂无

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

相关问题 错误:在Mac上找不到模块&#39;../build/Release/bson&#39; - Error: Cannot find module '../build/Release/bson' on Mac Microsoft NodeJS从零到英雄:找不到模块&#39;../build/Release/bson&#39;和TypeError:无法读取未定义的属性&#39;indexOf&#39; - Microsoft NodeJS Zero to Hero: Cannot find module '../build/Release/bson' and TypeError: Cannot read property 'indexOf' of undefined 错误:找不到模块“./build/Release/sharp” - Error: Cannot find module './build/Release/sharp' 找不到模块 &#39;../build/Release/bson&#39;] 代码:&#39;MODULE_NOT_FOUND&#39; } js-bson:无法加载 c++ bson 扩展,使用纯 JS 版本 - Cannot find module '../build/Release/bson'] code: 'MODULE_NOT_FOUND' } js-bson: Failed to load c++ bson extension, using pure JS version 运行节点脚本时出错,找不到模块&#39;mongodb / node_modules / bson&#39; - Error when running node script , Cannot find module 'mongodb/node_modules/bson' 找不到模块&#39;mongodb / node_modules / bson&#39; - Cannot find module 'mongodb/node_modules/bson' Vogels错误:错误:找不到模块&#39;./build/Release/DTraceProviderBindings&#39; - Vogels err: Error: Cannot find module './build/Release/DTraceProviderBindings' Rocket.Chat构建失败,错误为“找不到模块&#39;../build/Release/sharp.node&#39;” - Rocket.Chat build failing with error “Cannot find module '../build/Release/sharp.node' ” 找不到模块'../build/Release/opencv4nodejs - Cannot find module '../build/Release/opencv4nodejs 流星-未捕获的错误:找不到模块&#39;mongodb&#39; - Meteor - Uncaught Error: Cannot find module 'mongodb'
 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM