Vite + Transloadit: Uncaught TypeError: Cannot read properties of undefined (reading 'Resolver')

Vite + Transloadit: Uncaught TypeError: Cannot read properties of undefined (reading 'Resolver')

我正在开发一个 Vite 应用程序 (Vue 3.x),它使用 Transloadit 进行某些操作 images/PDFs。我在添加 Transloadit 库时 运行 遇到了一些错误(我正在创建自己的插件来包装 Transloadit)。

我已经通过添加以下内容解决了 Vite 删除 process 引起的错误:

define: {
    'process.versions': process.versions
  }

给我的 vite.config.js.

我现在得到的错误是:

Uncaught TypeError: Cannot read properties of undefined (reading 'Resolver')
    at node_modules/cacheable-lookup/source/index.js (index.js:7)
    at __require2 (chunk-IHTDASF6.js?v=e96a9976:17)
    at node_modules/got/dist/source/core/index.js (index.js:12)
    at __require2 (chunk-IHTDASF6.js?v=e96a9976:17)
    at node_modules/got/dist/source/as-promise/types.js (types.js:14)
    at __require2 (chunk-IHTDASF6.js?v=e96a9976:17)
    at node_modules/got/dist/source/as-promise/index.js (index.js:16)
    at __require2 (chunk-IHTDASF6.js?v=e96a9976:17)
    at node_modules/got/dist/source/create.js (create.js:15)
    at __require2 (chunk-IHTDASF6.js?v=e96a9976:17)

扩展我得到的浏览器堆栈跟踪:

node_modules/cacheable-lookup/source/index.js   @   index.js:7
__require2  @   chunk-IHTDASF6.js?v=e96a9976:17
node_modules/got/dist/source/core/index.js  @   index.js:12
__require2  @   chunk-IHTDASF6.js?v=e96a9976:17
node_modules/got/dist/source/as-promise/types.js    @   types.js:14
__require2  @   chunk-IHTDASF6.js?v=e96a9976:17
node_modules/got/dist/source/as-promise/index.js    @   index.js:16
__require2  @   chunk-IHTDASF6.js?v=e96a9976:17
node_modules/got/dist/source/create.js  @   create.js:15
__require2  @   chunk-IHTDASF6.js?v=e96a9976:17
node_modules/got/dist/source/index.js   @   index.js:14
__require2  @   chunk-IHTDASF6.js?v=e96a9976:17
node_modules/transloadit/src/Transloadit.js @   Transloadit.js:1
__require2  @   chunk-IHTDASF6.js?v=e96a9976:17
node_modules/transloadit/index.js   @   index.js:1
__require2  @   chunk-IHTDASF6.js?v=e96a9976:17
(anonymous) @   dep:transloadit:1

我的依赖项:

"dependencies": {
    "@auth0/auth0-spa-js": "1.18.0",
    "axios": "0.21.2",
    "transloadit": "3.0.2",
    "vue": "3.2.12",
    "vue-router": "4"
  }

我不再尝试直接在前端使用 Transloadit。我为此为 Transloadit 团队创建了一个问题,他们表示该库旨在从后端使用。我最终使用了 Uppy (uppy.io)[https://uppy.io/],这是由 Transloadit 团队制作的,通过 Uppy 我设法使用了转载它。如果您不想自己实施 Transloadit,我会推荐这个。