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 Report]: can't install electron correctly #2099

Open
Super1Windcloud opened this issue Feb 21, 2025 · 5 comments
Open

[Bug Report]: can't install electron correctly #2099

Super1Windcloud opened this issue Feb 21, 2025 · 5 comments

Comments

@Super1Windcloud
Copy link

Steps to reproduce

heme 5 : kali
[ Farm ] Using config file at C:\Users\superuse\super\vite\farm_electron\farm.config.ts
[ Farm ] Error: Failed to start the server
Caused by: Error: Failed to load farm config file: Electron failed to install correctly, please delete node_modules/electron and try installing again.
Potential solutions:

  1. Try set FARM_CONFIG_FORMAT=cjs(default to esm)
  2. Try set FARM_CONFIG_FULL_BUNDLE=1
    Error: Electron failed to install correctly, please delete node_modules/electron and try installing again
    at getElectronPath (C:\Users\superuse\super\vite\farm_electron\node_modules.pnpm\[email protected]\node_modules\electron\index.js:17:11)
    at Object. (C:\Users\superuse\super\vite\farm_electron\node_modules.pnpm\[email protected]\node_modules\electron\index.js:21:18)
    at Module._compile (node:internal/modules/cjs/loader:1546:14)
    at Module._extensions..js (node:internal/modules/cjs/loader:1691:10)
    at Module.load (node:internal/modules/cjs/loader:1317:32)
    at Module._load (node:internal/modules/cjs/loader:1127:12)
    at TracingChannel.traceSync (node:diagnostics_channel:315:14)
    at wrapModuleLoad (node:internal/modules/cjs/loader:217:24)
    at cjsLoader (node:internal/modules/esm/translators:329:5)
    at ModuleWrap. (node:internal/modules/esm/translators:260:7)
    at loadConfigFile (file:///C:/Users/superuse/super/vite/farm_electron/node_modules/.pnpm/@[email protected]/node_modules/@farmfe/core/dist/config/index.js:621:15)
    at async resolveConfig (file:///C:/Users/superuse/super/vite/farm_electron/node_modules/.pnpm/@[email protected]/node_modules/@farmfe/core/dist/config/index.js:65:34)
    at async start (file:///C:/Users/superuse/super/vite/farm_electron/node_modules/.pnpm/@[email protected]/node_modules/@farmfe/core/dist/index.js:28:36)
    at async handleAsyncOperationErrors (file:///C:/Users/superuse/super/vite/farm_electron/node_modules/.pnpm/@[email protected]/node_modules/@farmfe/cli/dist/utils.js:111:9)
     ELIFECYCLE  Command failed with exit code 1.

Reproduce link

No response

What is actually happening?

刚开始还可以启动 ,安装了一些依赖就报错了 ,提示没有正确安装electron, 卸载 nodes_module 之后重新安装依旧是这样

{
"name": "farm_electron",
"version": "1.0.0",
"main": "dist-electron/main.js",
"type": "module",
"scripts": {
"dev": "farm",
"build": "farm build && electron-forge package",
"clean": "farm clean",
"farm": "farm"
},
"dependencies": {
"express": "^4.21.2",
"node-fetch": "^3.3.2",
"react": "18",
"react-dom": "18",
"styled-components": "^6.1.15",
"ws": "^8.18.0",
"yup": "^1.6.1"
},
"devDependencies": {
"@electron-forge/cli": "^7.4.0",
"@electron-forge/maker-deb": "^7.4.0",
"@electron-forge/maker-rpm": "^7.4.0",
"@electron-forge/maker-squirrel": "^7.4.0",
"@electron-forge/maker-zip": "^7.4.0",
"@electron-forge/shared-types": "^7.4.0",
"@farmfe/cli": "^1.0.2",
"@farmfe/core": "^1.3.0",
"@farmfe/js-plugin-electron": "^1.0.0",
"@farmfe/plugin-react": "^1.2.0",
"@types/react": "18",
"@types/react-dom": "18",
"@types/styled-components": "^5.1.34",
"core-js": "^3.36.1",
"electron": "^34.2.0",
"fs-extra": "^11.2.0",
"react-refresh": "^0.14.0"
},
"resolutions": {
"styled-components": "^5"
}
}

System Info

System:
    OS: Windows 11 10.0.26100
    CPU: (20) x64 12th Gen Intel(R) Core(TM) i9-12900H
    Memory: 6.92 GB / 31.71 GB
  Binaries:
    Node: 22.9.0 - ~\AppData\Local\fnm_multishells\87728_1740130582678\node.EXE
    Yarn: 1.22.22 - A:\Scoop\apps\yarn\current\bin\yarn.CMD
    npm: 10.8.3 - ~\AppData\Local\fnm_multishells\87728_1740130582678\npm.CMD
    pnpm: 10.4.1 - A:\pnpm\pnpm.CMD
    bun: 1.1.29 - A:\Scoop\shims\bun.EXE
  Browsers:
    Chrome: bookmarks.html
initial_preferences
    Internet Explorer: 11.0.26100.1882
  npmPackages:
    @farmfe/core: ^1.3.0 => 1.6.6
@wre232114
Copy link
Member

我们看一下

@Super1Windcloud
Copy link
Author

Super1Windcloud commented Feb 22, 2025

pnpm 版本大更新了 , 默认阻止 “preinstall”、“install” 和 “postinstall” 预安装脚本的执行

这绝对是 该作者最愚蠢的决定, 相信未来一定会引发无数多的问题 , 因为非常多的客户端使用的dev依赖 使用二进制进行分发, 并且安装时不会报错, 而是运行时报错, 这也意味着pnpm将彻底远离客户端的领域, 只能苟且于前端

@fu050409
Copy link
Member

pnpm 版本大更新了 , 默认阻止 “preinstall”、“install” 和 “postinstall” 预安装脚本的执行
这绝对是 该作者最愚蠢的决定, 相信未来一定会引发无数多的问题 , 因为非常多的客户端使用的dev依赖 使用二进制进行分发, 并且安装时不会报错, 而是运行时报错, 这也意味着pnpm将彻底远离客户端的领域, 只能苟且于前端

无论如何 pnpm 这样做的确可以规避一些风险,也让用户可以精细化控制运行的 postscript,或许设计上他们应该使用黑名单模式而不是白名单模式,或者像 Arch Linux 在安装新的包之前或者在安装脚本更新之后每次询问?我并不是 pnpm 的开发者,这只是一些个人看法。

关于这个@wre232114 ,我们是否应该为 pnpm 更新我们的相关模板?我希望在 v2 之前重写我们的 create-farm 模块,现在正在进行这个工作,我可以在随后 PR 中一并处理它,新的模式中应该可以处理不同包管理器和不同模板之间的差异。

@nonzzz
Copy link
Member

nonzzz commented Feb 23, 2025

pnpm v10 blog pnpm 其实对于风险报告这件事的处理一直很头疼。尤其是之前发生的供应链攻击。这种方式并没有很好的解决方案。社区激进一点的说法是通过签名验证。 而pnpmv10选择阻止脚本, 这里有个解决方案 https://github.com/haoqunjiang/build-scripts-allowlist

@wre232114
Copy link
Member

pnpm 版本大更新了 , 默认阻止 “preinstall”、“install” 和 “postinstall” 预安装脚本的执行
这绝对是 该作者最愚蠢的决定, 相信未来一定会引发无数多的问题 , 因为非常多的客户端使用的dev依赖 使用二进制进行分发, 并且安装时不会报错, 而是运行时报错, 这也意味着pnpm将彻底远离客户端的领域, 只能苟且于前端

无论如何 pnpm 这样做的确可以规避一些风险,也让用户可以精细化控制运行的 postscript,或许设计上他们应该使用黑名单模式而不是白名单模式,或者像 Arch Linux 在安装新的包之前或者在安装脚本更新之后每次询问?我并不是 pnpm 的开发者,这只是一些个人看法。

关于这个@wre232114 ,我们是否应该为 pnpm 更新我们的相关模板?我希望在 v2 之前重写我们的 create-farm 模块,现在正在进行这个工作,我可以在随后 PR 中一并处理它,新的模式中应该可以处理不同包管理器和不同模板之间的差异。

模板需要更新一下

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

4 participants