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

[Bug] Error [ERR_REQUIRE_ESM]: require() of ES Module not supported. #203

Open
clark-tan opened this issue Feb 29, 2024 · 2 comments
Open
Labels
bug Something isn't working

Comments

@clark-tan
Copy link

Describe the bug

Error [ERR_REQUIRE_ESM]: require() of ES Module E:\test\electron-vite-react-main\dist-electron\main\index.js from E:\test\electron-vite-react-main\node_modules\electron\dist\resources\default_app.asar\main.js not supported.

我克隆下来更新了一下package.json,下面是我的包版本,运行起来后报错上面那个错误,请问应该怎么处理?
node版本为v18.16.1

{
"name": "electron-vite-react",
"version": "2.2.0",
"main": "dist-electron/main/index.js",
"description": "Electron Vite React boilerplate.",
"author": "草鞋没号 [email protected]",
"license": "MIT",
"private": true,
"debug": {
"env": {
"VITE_DEV_SERVER_URL": "http://127.0.0.1:7777/"
}
},
"type": "module",
"scripts": {
"dev": "vite",
"build": "tsc && vite build && electron-builder",
"preview": "vite preview",
"pree2e": "vite build --mode=test",
"e2e": "playwright test"
},
"dependencies": {
"electron-updater": "6.1.7"
},
"devDependencies": {
"@playwright/test": "1.42.0",
"@types/react": "18.2.60",
"@types/react-dom": "18.2.19",
"@vitejs/plugin-react": "4.2.1",
"autoprefixer": "10.4.17",
"electron": "22.3.12",
"electron-builder": "24.12.0",
"postcss": "8.4.35",
"react": "^18.2.0",
"react-dom": "^18.2.0",
"tailwindcss": "^3.3.3",
"typescript": "5.1.6",
"vite": "5.0.10",
"vite-plugin-electron": "^0.28.0",
"vite-plugin-electron-renderer": "^0.14.5"
}
}

@clark-tan clark-tan added the bug Something isn't working label Feb 29, 2024
@zacard-orc
Copy link

+1
我碰到相同的问题,项目被type:module限制住了,但是一放开,还有很多地方要调整

@caoxiemeihao
Copy link
Member

caoxiemeihao commented Mar 11, 2024

暂时来说,使用 "type": "module" 和整个 Node.js 的生态有很多不兼容的地方,尤其是 C/C++ 扩展。

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
bug Something isn't working
Projects
None yet
Development

No branches or pull requests

3 participants