我正在尝试使用我的Electron应用程序中的node-7z来解密受密码保护的zip文件,但每当我传递密码时,我都会收到一个错误。当我console.log 7zip-bin.path7za时,我得到了一个有效的可执行文件。如果我解压一个没有任何密码的压缩包,没有任何问题,并且我已经在项目根目录和节点模块文件夹中运行了npm install,那么我还遗漏了什么吗?
谢谢你的帮助。
const { extractFull } = require('node-7z')
const zipbin = require('7zip-bin')
let testFile = zipLocation + "/zip.zip";
const pathTo7zip = zipbin.path7za;
console.log(pathTo7zip); -->Returns .z7a file path
const myStream = extractFull(testFile, installLocation, { password: 'password' }, {
$bin: pathTo7zip,
$progress: true
})
myStream.on('error', (err) => handleError(err));
}如果我使用p:或password:添加密码,则会得到以下错误:
Error: spawn 7z ENOENT
at notFoundError (***app\node_modules\cross-spawn\lib\enoent.js:6)
at verifyENOENT (****app\node_modules\cross-spawn\lib\enoent.js:40)
at ChildProcess.cp.emit (*****app\node_modules\cross-spawn\lib\enoent.js:27)
at Process.ChildProcess._handle.onexit (internal/child_process.js:272)没有密码,我没有问题,但是我使用node-7z的全部原因是为了zip/.7z加密。
发布于 2021-08-19 00:43:25
这可能有点晚了,但如果有人像我一样偶然发现了这篇文章,这里有解决方案。
正如在这里的回答中提到的:electron-packager spawn ENOENT
npm install fix-path (https://www.npmjs.com/package/fix-path)electron-main.js中运行它
const fixPath = require('fix-path');
// or
import fixPath from 'fix-path';
fixPath();
发生这种情况的原因在包的描述中有些解释:
macOS上的
图形用户界面应用程序不继承您的点文件中定义的$PATH。
https://stackoverflow.com/questions/67750181
复制相似问题