在我的项目中不能导入PouchDB

我正在从事一个项目,最近PouchDB决定停止工作。 我不能在我的ts项目中编译它。 我试过了:

import * as PouchDB from 'pouchdb'; export default PouchDB.defaults({ prefix: `http://admin:password@localhost:5984/` }) 

但是我明白了

 server/src/database.ts(3,24): error TS2339: Property 'defaults' does not exist on type 'typeof 'pouchdb''. 

如果我尝试:

 import {PouchDB} from 'pouchdb'; export default PouchDB.defaults({ prefix: `http://admin:password@localhost:5984/` } as any) 

我明白了

 server/src/database.ts(1,9): error TS2305: Module ''pouchdb'' has no exported member 'PouchDB'. 

如果我尝试:

 import PouchDB from 'pouchdb'; export default PouchDB.defaults({ prefix: `http://admin:password@localhost:5984/` } as any) 

然后它会编译,但我运行它时得到这个:

 export default PouchDB.defaults({ ^ TypeError: Cannot read property 'defaults' of undefined at Object.<anonymous> ... 

如果我尝试:

  const PouchDB = require('pouchdb'); 

我失去了每一个打字,所以它成为我不想要的anytypes

 ❯ npm ls pouchdb @types/pouchdb compactd@0.0.0 /mnt/c/Users/Vincent/Documents/GitHub/compactd ├── @types/pouchdb@6.3.0 └── pouchdb@6.3.4 

我停止工作之前唯一做的是清理node_modules并使用npm而不是纱线重新安装(每当我安装一些东西时,yarn都要重新编译所有本地模块,但是我觉得npm也是这样做的)

我试图降级PouchDB到6.2.0,我已经尝试了一切,这是让我疯狂的任何帮助将非常感激。

使用TS节点,我试图要求/每一个可能的方式导入PouchDB:

 > require('pouchdb') { [Function: PouchDB$5] super_: { [Function: AbstractPouchDB] super_: { [Function: EventEmitter] EventEmitter: [Object], usingDomains: true, defaultMaxListeners: [Getter/Setter], init: [Function], listenerCount: [Function] } }, adapters:... > import PouchDB from 'pouchdb' undefined > PouchDB undefined > import * as PouchDB from 'pouchdb' [eval].ts:2 Object.defineProperty(exports, "__esModule", { value: true }); ^ ReferenceError: exports is not defined at [eval].ts:2:23 at ContextifyScript.Script.runInContext (vm.js:53:29) at ContextifyScript.Script.runInNewContext (vm.js:59:15) at _eval (/home/vincent/.nvm/versions/node/v8.5.0/lib/node_modules/ts-node/dist/_bin.js:181:29) at REPLServer.replEval (/home/vincent/.nvm/versions/node/v8.5.0/lib/node_modules/ts-node/dist/_bin.js:220:18) at bound (domain.js:301:14) at REPLServer.runBound [as eval] (domain.js:314:12) at REPLServer.onLine (repl.js:440:10) at emitOne (events.js:115:13) at REPLServer.emit (events.js:210:7) > import {PouchDB} from 'pouchdb' Thrown: ⨯ Unable to compile TypeScript [eval].ts (1,9): Module ''pouchdb'' has no exported member 'PouchDB'. (2305) 

截至目前,最好的解决办法是:

 import Pouch from 'pouchdb'; const PouchDB: typeof Pouch = require('pouchdb'); 

这是快速和肮脏的,但真正的修复需要由pouchDB维护人员完成