我目前正在尝试构建我的电子应用程序。 为此,我正在使用 Electron Forge。 当我运行 npm start 时一切正常,但是当我尝试使用 npm run make 构建它时 我收到以下错误行:
An unhandled rejection has occurred inside Forge:
[Error: ENOENT: no such file or directory, rename 'C:\Users\RENERE~1\AppData\Local\Temp\electron-packager\win32-x64\yt-downloader-win32-x64\electron.exe' -> 'C:\Users\RENERE~1\AppData\Local\Temp\electron-packager\win32-x64\yt-downloader-win32-x64\yt-downloader.exe'] {
errno: -4058,
code: 'ENOENT',
syscall: 'rename',
path: 'C:\\Users\\RENERE~1\\AppData\\Local\\Temp\\electron-packager\\win32-x64\\yt-downloader-win32-x64\\electron.exe',
dest: 'C:\\Users\\RENERE~1\\AppData\\Local\\Temp\\electron-packager\\win32-x64\\yt-downloader-win32-x64\\yt-downloader.exe'
}
这是 package.json 文件:
{
"name": "yt-downloader",
"productName": "yt-downloader",
"version": "1.0.0",
"description": "Download from Youtube",
"main": "index.js",
"scripts": {
"start": "electron-forge start",
"package": "electron-forge package",
"make": "electron-forge make",
"publish": "electron-forge publish",
"lint": "echo \"No linting configured\""
},
"keywords": [],
"author": {
"name": "Remling97",
"email": "[email protected]"
},
"license": "MIT",
"config": {
"forge": {
"packagerConfig": {},
"makers": [
{
"name": "@electron-forge/maker-squirrel",
"config": {
"name": "yt_downloader"
}
},
{
"name": "@electron-forge/maker-zip",
"platforms": [
"darwin"
]
},
{
"name": "@electron-forge/maker-deb",
"config": {}
},
{
"name": "@electron-forge/maker-rpm",
"config": {}
}
]
}
},
"dependencies": {
"electron-squirrel-startup": "^1.0.0",
"ytdl-core": "^2.0.0",
"ytpl": "^0.1.20"
},
"devDependencies": {
"@electron-forge/cli": "6.0.0-beta.50",
"@electron-forge/maker-deb": "6.0.0-beta.50",
"@electron-forge/maker-rpm": "6.0.0-beta.50",
"@electron-forge/maker-squirrel": "6.0.0-beta.50",
"@electron-forge/maker-zip": "6.0.0-beta.50",
"electron": "8.1.0"
}
}
我无法在网上找到为什么会发生这种情况的答案。谁能帮助我吗?我已经尝试重新安装 Electron、Electron-Forge 和 NodeJS,但没有任何效果。
如果其他人遇到此错误并且无法找到解决方案:
该错误已报告给 Github 上的电子打包程序,并已转发到可能导致该错误的依赖项。尽管该问题已解决并且据称已经修复,但我仍然遇到该问题,并且我认为重命名 Windows 用户并不是一个令人满意的解决方案。
根据一位用户的说法,@electron-forge/maker-zip
固定到版本6.0.0-beta.47
,但它对我不起作用。
我找到了解决办法, 我添加了
"electron-prebuilt-compile": "4.0.0"
作为开发依赖项,它起作用了。 (它不能是 ^4.0.0 或类似的范围,它必须是像 4.0.0 这样的精确版本,否则 electro-forge 会给出以下错误)
Electron forge was terminated:
You must depend on an EXACT version of "electron-prebuilt-compile" not a range (got "^4.0.0")
终于找到解决办法了。将自动下载设置为 false
autoUpdater.autoDownload = false;
在我的例子中,应用程序运行后下载了两次。