- android - RelativeLayout 背景可绘制重叠内容
- android - 如何链接 cpufeatures lib 以获取 native android 库?
- java - OnItemClickListener 不起作用,但 OnLongItemClickListener 在自定义 ListView 中起作用
- java - Android 文件转字符串
我完成了一个非常简单的 mongodb 教程,其中我们使用 mongo shell 创建了一个数据库,创建了一个集合,然后编写了一个非常简单的 nodejs 程序来访问集合并将文档记录到控制台。
var mongodb = require('mongodb');
var db = new mongodb.Db('mcfly', new mongodb.Server('127.0.0.1', 27017), {safe: true});
db.open(function(err) {
db.collection('mathpeeps', function(err, collection){
collection.find().toArray(function(err, items){
console.log(items)
});
});
});
但是当我运行程序时,它会给我:
js-bson: Failed to load c++ bson extension, using pure JS version
[ { _id: 53ab29bbdb49942ae25b5201,
firstname: 'Leonard',
lastname: 'Euler',
born: 1707 },
{ _id: 53ab29fedb49942ae25b5202,
firstname: 'Karl',
lastname: 'Gauss' } ]
我在 SO 上搜索并搜索了“js-bson:无法加载 c++ bson 扩展,使用纯 JS 版本”并尝试了所有方法,除了对其他人不起作用的答案或围绕 mongoose 问题的答案我在这个练习中没有使用 Mongoose 。
到目前为止我已经尝试过的一些事情:
sudo apt-get install gcc make build-essential
rm -rf node_modules
npm cache clean
npm install
(但本练习甚至不使用 package.json 文件)
我尝试用最新版本重新安装 node-mongodb
我试过了
npm install -g node-gyp
我在 SO 这里尝试了一个答案 Failed to load c++ bson extension :
进入 node_modules/mongodb/node_modules/bson 目录并从那里使用
node-gyp rebuild
然后产生:
gyp info it worked if it ends with ok
gyp info using node-gyp@0.13.1
gyp info using node@0.11.9-pre | linux | x64
gyp ERR! configure error
gyp ERR! stack Error: "pre" versions of node cannot be installed, use the --nodedir flag instead
gyp ERR! stack at install (/usr/local/lib/node_modules/node- gyp/lib/install.js:66:16)
gyp ERR! stack at Object.self.commands.(anonymous function) [as install] (/usr/local/lib/node_modules/node-gyp/lib/node-gyp.js:66:37)
gyp ERR! stack at getNodeDir (/usr/local/lib/node_modules/node- gyp/lib/configure.js:152:20)
gyp ERR! stack at /usr/local/lib/node_modules/node-gyp/lib/configure.js:95:9
gyp ERR! stack at ChildProcess.exithandler (child_process.js:659:7)
gyp ERR! stack at ChildProcess.EventEmitter.emit (events.js:106:17)
gyp ERR! stack at maybeClose (child_process.js:773:16)
gyp ERR! stack at Socket.<anonymous> (child_process.js:986:11)
gyp ERR! stack at Socket.EventEmitter.emit (events.js:103:17)
gyp ERR! stack at Pipe.close (net.js:458:12)
gyp ERR! System Linux 3.13.0-29-generic
gyp ERR! command "node" "/usr/local/bin/node-gyp" "rebuild"
gyp ERR! cwd /home/nathaniel/node_modules/mongodb/node_modules/bson
gyp ERR! node -v v0.11.9-pre
gyp ERR! node-gyp -v v0.13.1
gyp ERR! not ok
我在这里看到了一个 SO 答案 Failed to load c++ bson extension, using pure JS version说:
“听起来你在使用 npm 安装 bson 模块时没有安装 gcc/g++/make/python 2.x。尝试先安装它们,然后使用 npm 重新安装 bson。”
但是这个答案没有被选为解决方案,我不知道这意味着什么,因为我是一个严肃的菜鸟。
我真的很想继续学习 mongodb,但我不希望一些包 bug 导致 future 出现问题,让我错误地认为我做错了什么。我真的很想现在就把它弄清楚。
我还注意到许多发布此问题的其他人(没有 mongoose 或没有明确参与)没有选择答案或回复说他们解决了这个问题。
我正在运行 Ubuntu 14.04 LTS 和 Node v0.11.9-pre
任何帮助将不胜感激!!!!
最佳答案
我认为错误非常明确:错误:无法安装 Node 的“pre”版本,请改用 --nodedir 标志
。因此,您应该提供从安装 Node 的根 Node 源目录的路径,或者安装/使用实际 Node 版本(v0.11.13 是最新的不稳定版本,v0.10.29 是最新的稳定版本在撰写本文时发布)并再次尝试 npm install
/node-gyp rebuild
。
它要求 Node 源目录的原因是因为 node-gyp 必须从 nodejs.org 站点下载 Node 源 tarball 才能编译插件(它需要 C++ 头文件等)。但是,如果您有一个预发布的 Node 版本,node-gyp 无法知道要下载什么源代码树以匹配您已安装的内容。
关于node.js - 无法加载 c++ bson 扩展,使用纯 JS 版本——没有 Mongoose ,没有 express ,只有 Node 驱动程序,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/24440768/
我试图理解 BSON 符号 来自网站 BSON Site .但是,我无法理解相关性背后的原因。 我也提到了以下问题,但由于以下原因,我不相信。 Question 1 : 不熟悉 ruby 实现 Que
我收到以下错误: { [Error: Cannot find module '../build/Release/bson'] code: 'MODULE_NOT_FOUND' } js-bson:
假设我们有一个字符串,里面有二进制 bson 数据。如何加载到 bson object ? 最佳答案 我想在同一个页面上有一个例子可以做到这一点: BSONObjBuilder b; b << "na
我正在寻找如下所示的 type_of 方法: import bson bson.type_of(42) # it should return "int". bson.type_of("hello")
Base64 编码的 BSON 比 BSON 小吗? 最佳答案 Piskvor 的权利,base64 编码的任何东西都比原始长。您对某些内容进行 base64 编码以使其进入具有有限字符轨道的 cha
目前正在做一个 Golang 项目,但我得到了一些 Controller package controller import ( "go.mongodb.org/mongo-driver
这个特定的问题与使用 mongodb 和 golang 包 mongo-driver 相关。 ,但我认为这适用于与 mongodb 的大多数接口(interface)。 使用 Find 时要从集合中查
目前正在做一个 Golang 项目,但我得到了一些 Controller package controller import ( "go.mongodb.org/mongo-driver
可能相关:How to use interface type as a model in mgo (Go)? 我有一个像这样的结构: type Game struct { ID b
有没有一种方法可以使用 MongoDB C++ 驱动程序中的 BSON() 宏来生成 BSON 将空值。例如,为了生成一个 BSON 来表示这个文档:{"a": "foo", "b": null}:
我通过以下两种不同的方法生成了一个 ObjectId: user@ubuntu:~$ python Python 2.7.1+ (r271:86832, Apr 11 2011, 18:05:24)
我如何转换 BsonDocument到 FilterDefinition实例? 它是新的 MongoDb C# 驱动程序提供的类。 最佳答案 BsonDocument 和 FilterDefiniti
我正在尝试从 Json 生成 Bson。我尝试使用 Json.Net,但似乎有记录的行为,其中库为整数字段生成 uint64。不幸的是,我们必须使用 uint32。 因此我正在尝试使用 mongodb
我正在使用 https://github.com/mongodb/mongo-go-driver和目前正在尝试实现此类结构的部分更新 type NoteUpdate struct { ID
我目前正在尝试读取 bson 文件以将其导入数据库。我已经可以读取该文件并将其作为字节打印,但最终只收到 bson.errors.InvalidBSON: objsize Too Large 错误。
我尝试在 arch linux 迷你计算机(cubox)上安装 mean.io 堆栈。所以我安装了 nodejs 和 mongodb 包。 我用 Git 检索了堆栈,进行了 npm 安装(没问题)但是
为什么会输出false?我期待 true... package main import ( "fmt" "time" "gopkg.in/mgo.v2/bson" )
这是一种愚蠢的语法错误,尝试了很多方法,但都无法正常工作,请大家帮忙。 使用 mgo 在 Go 中使用 MongoDB,我只是尝试简化 $ne 运算符的使用,代码如下所示,但不断出现编译语法错误: l
我设置了新的 Typescript/React 项目,在 tsconfig.json 文件中收到此错误消息 "找不到 'bson' 的类型定义文件。该文件在程序中,因为:隐式类型库 'bson' 的入
我尝试将数据从 SQL Server 迁移到 MongoDB,但在将数据导入到 MongoDB 的最后阶段遇到了以下类型错误。 mongoImp = dbo.insert_many(jArray)
我是一名优秀的程序员,十分优秀!