我试图在我的SvelteKit/Vite应用程序中使用库节点-imap。我用import * as Imap from "imap";导入库。当我尝试运行我的应用程序时,我会得到以下错误:
process is not defined
ReferenceError: process is not defined
at node_modules/.pnpm/utf7@1.0.2/node_modules/utf7/utf7.js (http://localhost:3000/node_modules/.vite/deps/imap.js?v=e5efcf87:944:20)
at __require (http://localhost:3000/node_modules/.vite/deps/chunk-OL3AADLO.js?v=e5efcf87:9:50)
at node_modules/.pnpm/imap@0.8.19/node_modules/imap/lib/Connection.js (http://localhost:3000/node_modules/.vite/deps/imap.js?v=e5efcf87:5022:16)
at __require (http://localhost:3000/node_modules/.vite/deps/chunk-OL3AADLO.js?v=e5efcf87:9:50)
at http://localhost:3000/node_modules/.vite/deps/imap.js?v=e5efcf87:6690:20问题似乎是Vite/Svelte不支持process,而是使用import.meta.env作为环境变量。我怎样才能让图书馆工作呢?
https://stackoverflow.com/questions/72910190
复制相似问题