未捕获类型错误。PouchDB不是一个构造函数

问题描述 投票:1回答:1

我很难理解这个错误。Uncaught TypeError: PouchDB is not constructor: PouchDB不是一个构造函数

代码如下。

var PouchDB = require("pouchdb");
var db = new PouchDB("scr");

我读到过关于它可能与类型有关的信息 I've read about how it may be related to types and that adding:

 "@types/node": "^10.12.0",
 "@types/pouchdb": "^6.3.2",

添加到我的package.json中应该会有帮助,但它没有。我在另一个简单的.js文件上进行了测试,工作正常,但在我的主应用程序上却不行。不过,我还是不明白为什么它不能工作。小袋的文档很清楚 https:/pouchdb.comapi.html#create_document。.

我应该提到,我是在电子应用的上下文中运行的,而不是在浏览器中。

在这一点上,我很困惑,任何帮助将是非常感激的。干杯

javascript node.js electron pouchdb
1个回答
0
投票

对于没有构造函数的使用.default

const PouchDB = require('pouchdb').default;
© www.soinside.com 2019 - 2024. All rights reserved.