MongoDB - 错误:找不到模块“./build/Release/bson”
MongoDB - Error: Cannot find module '../build/Release/bson'
我尝试以下列方式运行打字稿示例,导致以下错误:
$ 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
此外,查看db.ts,我认为package.json
文件中缺少http
和url
,对吗?
如何使用 mongodb 修复上述错误?
在 Linux 操作系统中,首先从 node_modules
中删除 bson 文件夹并运行以下命令:
sudo apt-get install gcc make build-essential
然后重新启动 NodeJS 文件,例如 index.js
。希望它有帮助
我正在使用connect-mongo进行会话。我遇到了同样的问题,这是因为connect-mongo的版本在猫鼬的4.0.x版本中产生了错误。您可以检查正在使用的每个版本的依赖项。
看着db.ts,我认为package.json文件中缺少http和url,对吗?
不。这些模块是核心节点j的一部分。
错误的源是 package.json 指定最小数量,而不向后使用兼容的版本锁。 https://github.com/Microsoft/TypeScriptSamples/blob/master/imageboard/package.json#L6 我会将">="更改为更难的版本,例如 3.x
相关文章:
- 使用Phonegap Build后,谷歌地图将不会显示在手机上
- HTML5 Drag Release offsetX offsetY jump
- Dojo Build System - 使用带有谷歌地图API的异步插件
- Can't get Sublime Javascript Build to work
- Cordova InAppBrowser无法通过build.phonegap.com运行
- 页面更改无法在android上使用Phonegap Build的JqueryMobile中工作
- 找不到模块 './build/Release/bson'] 代码: 'MODULE_NOT_FOUND' } js-bs
- 有角度的“;未知提供者”;在约曼应用程序中使用Grunt Build缩小后出错
- Dojo Build-copyOnly在概要文件中不起作用
- phonegap build cordova.file is undefined
- 在PhoneGap Build中从Facebook获取信息
- 将Jasmine JavaScript单元测试与TFS Build CI集成的简单方法
- sqlite with javascript with phonegap using build.phonegap.co
- 当运行 generator-gulp-webapp 的 'build' 任务(使用 gulp-jade)
- MongoDB - 错误:找不到模块“./build/Release/bson”
- SVG Raphael jQuery Build path/trail
- PhoneGap Build Service "Build in HTML5, CSS, JavaScript
- InAppBrowser (PhoneGap Build 3.1.0) 事件不会在 Android 2.3 上触发
- Jenkins sonar build使用js失败
- 错误:找不到模块'/build/Release/sharp'