Vite + Transloadit:未捕获的类型错误:无法读取未定义的属性(读取“Resolver”)
2021-09-21
2023
我正在开发一个 Vite 应用程序 (Vue 3.x),它利用 Transloadit 对图像/PDF 进行一些操作。我在添加 Transloadit 库时遇到了一些错误(我正在创建自己的插件包装 Transloadit)。
我已经解决了由 Vite 删除
process
导致的错误,方法是将以下内容添加到我的
vite.config.js
中:
define: {
'process.versions': process.versions
}
。
我现在收到的错误是:
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"
}
1个回答
我不再尝试在前端直接使用 Transloadit。我向 Transloadit 团队提出了一个问题, 他们表示该库应该从后端使用 。我最终使用了由 Transloadit 团队制作的 Uppy (uppy.io)[https://uppy.io/],通过 Uppy 我设法使用了 Transloadit。如果您不想自己实施 Transloadit,我建议您使用它。
Gonzalo Hirsch
2022-03-24