got error spawn enoent in electron
NingerJohn opened this issue · 0 comments
NingerJohn commented
I am trying to use ffprobe in electron, while use command npm run electron:serve
, which is vue-cli-service electron:serve
, got errors as following
Uncaught Error: spawn D:\www\packages\vs-player\node_modules\electron\dist\resources\ffprobe.exe ENOENT events.js:177
at Process.ChildProcess._handle.onexit (internal/child_process.js:264)
at onErrorNT (internal/child_process.js:456)
at processTicksAndRejections (internal/process/task_queues.js:84)
errnoException @ internal/errors.js:463
ChildProcess._handle.onexit @ internal/child_process.js:264
onErrorNT @ internal/child_process.js:456
processTicksAndRejections @ internal/process/task_queues.js:84
The code I used is as following
let ffprobeStaticPath = ''
if (!__dirname.includes('.asar')) { // If dev
ffprobeStaticPath = require('ffprobe-static').path
} else { // if compiled
let ext = ''
if (process.platform === 'win32') ext = '.exe' // if windows
ffprobeStaticPath = path.join(process.resourcesPath + '/ffprobe' + ext)
}
const ffprobe = require('ffprobe');
ffprobe(filedir, { path: ffprobeStaticPath })
.then(function (info) {
console.log(info);
context.commit('saveListData', filedir, info);
})
FYI,I console.log the ffprobeStaticPath
,output is D:\www\packages\vs-player\node_modules\electron\dist\resources\electron.asar\renderer\bin\win32\x64\ffprobe.exe
In my opinion, the ffprobeStaticPath
should be like node_modules\ffprobe-static\bin\win32\x64\ffprobe.exe