Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Vite: Could not resolve "../build/Release/agora_node_ext" #1244

Open
showtan001 opened this issue Nov 29, 2024 · 2 comments
Open

Vite: Could not resolve "../build/Release/agora_node_ext" #1244

showtan001 opened this issue Nov 29, 2024 · 2 comments

Comments

@showtan001
Copy link

showtan001 commented Nov 29, 2024

Error occurred during Vite build:

image

Version:

"agora-electron-sdk": "^4.4.0",
"electron": "^22.3.27",
"electron-builder": "^23.6.0",
"vite": "^4.1.4",
"vite-electron-plugin": "^0.8.2",
"vite-plugin-electron": "^0.11.1"

I have already tried it https://electron-vite.github.io/guide/cpp-addons.html, It still doesn't work.

@showtan001 showtan001 changed the title Could not resolve "../build/Release/agora_node_ext" Vite: Could not resolve "../build/Release/agora_node_ext" Dec 3, 2024
@dingshaohua-com
Copy link

me too

@dingshaohua-com
Copy link

dingshaohua-com commented Dec 20, 2024

因为 agora-electron-sdk 属于 electron 进程的模块,且还用到了webpack 的能力!

所以若你的渲染进程(既renderer ,也就是web) 是现代化项目( 需要打包或者编译)的话,需要在渲染进程项目中 忽略此包被打包 或 编译 或依赖预构建 的步骤,也就是 需如下配置:


若您的项目为webapck项目 ,则需要项目中配置 webpack.config.js

{
  externals: {
   "agora-electron-sdk": "commonjs2 agora-electron-sdk"  // 排除agora-electron-sdk依赖项
  }
}

若您的项目为vite项目 ,则需要项目中配置 vite.config.js

{
  optimizeDeps: {
    exclude: ['agora-electron-sdk'] // 排除agora-electron-sdk依赖项
  }
}

不仅仅是此插件,在electron 集成 node 环境之后, 若在渲染进程中使用electron的模块或Node模块 最好都要这么处理!


对于项使用vite 和 electron结合的,这里我整理了完整的流程

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

2 participants