我使用 electron 和 imagemin 创建了一个基本的图像压缩应用程序,它在运行 usinnpm start
命令时工作正常。
之后,我使用电子打包器打包应用程序并运行 exe 文件并尝试再次压缩图像。
这次我得到了以下错误
Error: Error in file: path_to_image.jpg
write EPIPE
at afterWriteDispatched (internal/stream_base_commons.js:145)
at writeGeneric (internal/stream_base_commons.js:136)
at Socket._writeGeneric (net.js:703)
at Socket._write (net.js:715)
at doWrite (_stream_writable.js:415)
at writeOrBuffer (_stream_writable.js:399)
at Socket.Writable.write (_stream_writable.js:299)
at Socket.Writable.end (_stream_writable.js:584)
at Socket.end (net.js:531)
at handleInput (C:\Users\xyz\Desktop\slice\release-builds\slice-win32-ia32\resources\app.asar\node_modules\execa\index.js:87)`
这是下面的代码
const path = require('path')
const imagemin = require('imagemin');
const imageminMozjpeg = require('imagemin-mozjpeg');
const files = await imagemin(["path_to_image.jpg"], path.dirname(r) + '/optimized', {
plugins: [
imageminMozjpeg({
quality: document.getElementById('jq').value
})
]
}).then(file => {
console.log(file);
})
.catch(Error => console.log(Error));
打包应用程序时我缺少什么吗?