You need to enable JavaScript to run this app.
优惠活动
大模型
产品
解决方案
定价
更多

安装pouchdb后出现TS2661报错:无法导出Buffer,求解决方案

解决TS2661: Cannot export 'Buffer' 编译错误

执行npm install pouchdb @types/pouchdb后编译时报错:

ERROR
node_modules/@types/node/ts4.8/buffer.d.ts:98:14 - error TS2661: Cannot export 'Buffer'. Only local declarations can be exported from a module.
98 export { Buffer };

试试这些解决方案:

  • 升级TypeScript版本:这个错误大多是TS版本和@types/node版本不匹配导致的,把TS更到4.9及以上版本就行,跑这个命令:npm install typescript@latest --save-dev
  • 指定兼容的@types/node版本:不想升级TS的话,就装个适配当前TS4.8的@types/node版本,比如18.x系列:npm install @types/node@18 --save-dev
  • 跳过类型库检查:在tsconfig.json的compilerOptions里加"skipLibCheck": true,直接跳过库文件的类型检查,能快速绕开这个问题:
{
  "compilerOptions": {
    // 其他配置保留
    "skipLibCheck": true
  }
}
  • 重装依赖:删了node_modules和package-lock.json后重新装,有时候缓存也会搞出这种问题:
rm -rf node_modules package-lock.json
npm install

内容的提问来源于stack exchange,提问作者Nizal Sha

相关产品推荐
方舟 Agent Plan

超全模态模型 × Harness 升级,最新支持 Deepseek-V4.1-Flash、GLM-5.3 系列、Doubao-Seedream-5.0-pro、Kimi-K3 (部分), 限时 9.9 元起

最近更新时间:2026.08.13 00:20:24