I've tried instantiating a PouchDB instance in node REPL.

In REPL:

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

This always causes node to exit with the exception:

undefined:0
TypeError: undefined is not a function.

Can PouchDB be used in Node REPL?

有帮助吗?

解决方案 2

From a current pouchdb clone

~/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"
}
===
>

其他提示

it is literally just the basic repl that doesn't work, starting a custom repl works fine for some unknown reason so running node --eval "require('repl').start('> ');" works

许可以下: CC-BY-SA归因
不隶属于 StackOverflow
scroll top