umbrella22 / electron-vite-template

This project is a vue3 + Vite + electron project template composed of Vite and rollup. It has the same functions as my previous electron+Vue+template project
Other
398 stars 107 forks source link

__vite-browser-external:path:3 Uncaught Error: Module "path" has been externalized for browser compatibility and cannot be accessed in client code. #38

Closed kingdream123 closed 2 years ago

kingdream123 commented 2 years ago

在渲染层代码,引用 path 模块报错 请教下,这个怎么解决呀

完整错误信息如下: vite-browser-external:path:3 Uncaught Error: Module "path" has been externalized for browser compatibility and cannot be accessed in client code. at Object.get (vite-browser-external:path:3) at FileBufferTransport._createStream (file.ts:46) at FileBufferTransport.reload (file.ts:28) at new FileTransport (file.ts:16)

umbrella22 commented 2 years ago

不建议再渲染进程使用任何node模块,建议使用ipc或者严格分支的preload方案

kingdream123 commented 2 years ago

ok,本来想偷懒一把梭😄,最后还是用preload方案来做了