1

我尝试在节点 REPL 中实例化 PouchDB 实例。

在 REPL 中:

var pouchdb = require("pouchdb");
var foo = new pouchdb("foo");

这总是会导致节点退出并出现以下异常:

undefined:0
TypeError: undefined is not a function.

PouchDB 可以在 Node REPL 中使用吗?

4

2 回答 2

1

从字面上看,它只是基本的 repl 不起作用,由于某些未知原因,启动自定义 repl 可以正常工作,因此运行node --eval "require('repl').start('> ');"正常

于 2014-04-18T14:17:19.247 回答
0

从当前 pouchdb 克隆

~/src/pouchdb (master)$ npm run shell

> pouchdb@2.0.2-alpha shell /Users/daleharvey/src/pouchdb
> ./bin/repl.js

> var foo = new PouchDB('foo');
undefined
> foo.post({'a':'doc'});
[object Object]
>
==> leveldb foo bulkDocs
args: [{"docs":[{"a":"doc"}]},{},null]
result: [
  {
    "ok": true,
    "id": "3C8264BA-8966-4059-9FA2-401E464E54E8",
    "rev": "1-49e9d0c368f1114e0a0b67cdc808d6da"
  }
]
===
>
==> leveldb foo post
args: [{"a":"doc"}]
result: {
  "ok": true,
  "id": "3C8264BA-8966-4059-9FA2-401E464E54E8",
  "rev": "1-49e9d0c368f1114e0a0b67cdc808d6da"
}
===
>
于 2014-03-18T20:54:48.640 回答