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

Angular 17使用pdfjs-dist遇Top-level await环境兼容错误

使用pdfjs-dist库时遭遇Top-level await环境兼容错误

我在使用pdfjs-dist库时遇到如下错误:

Top-level await is not available in the configured target environment ("chrome119.0", "edge119.0", "firefox115.0", "ios16.0", "safari16.0" + 7 overrides)

触发错误的代码行:

/***/ webpack_exports = globalThis.pdfjsLib = await (globalThis.pdfjsLibPromise = webpack_exports);

我了解到有用户通过Vite解决过类似问题,但我的项目并未使用Vite。我已经尝试将tsconfig中的target从ES2022改为ESNext,不过问题依然存在。当前我的tsconfig配置如下:

{
  "compileOnSave": false,
  "compilerOptions": {
    "outDir": "./dist/out-tsc",
    "forceConsistentCasingInFileNames": true,
    "strict": true,
    "noImplicitOverride": true,
    "noPropertyAccessFromIndexSignature": true,
    "noImplicitReturns": true,
    "noFallthroughCasesInSwitch": true,
    "skipLibCheck": true,
    "esModuleInterop": true,
    "sourceMap": true,
    "declaration": false,
    "experimentalDecorators": true,
    "moduleResolution": "node",
    "importHelpers": true,
    "target": "ESNext",
    "module": "ESNext",
    "useDefineForClassFields": false,
    "lib": ["ESNext", "dom"]
  },
  "angularCompilerOptions": {
    "enableI18nLegacyMessageIdFormat": false,
    "strictInjectionParameters": true,
    "strictInputAccessModifiers": true,
    "strictTemplates": true
  }
}

内容的提问来源于stack exchange,提问作者f-accu

相关产品推荐
方舟 Agent Plan

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

最近更新时间:2026.07.02 01:07:18