JVKdouk / node-ebook-converter

Node.js minimal ebook converter (single package) with built in queue and threading functionalities.
MIT License
38 stars 6 forks source link

'MODULE_NOT_FOUND' when converting pdf to epub [ electron with CRA ] #1

Open 61soldiers opened 3 years ago

61soldiers commented 3 years ago

In main process

let pdfPath = path.parse(data.path)
// Convert with calibre
ebookConverter.convert({
  input: data.path,
  output: `${pdfPath.dir}/${pdfPath.name}.epub`,
  silent: true,
}).then(async (res) => await event.reply('convertPdfToEpub', {status: 'success'}))
  .catch(async (err) => await event.reply('convertPdfToEpub', {status: 'failed', err: err}))

It works in development but once i build the electron app and try to convert that error shows up. Note: I also have a check to see if ebook-convert command can be executed so the conversion only runs if check returns true

JVKdouk commented 3 years ago

I will be checking what is going on. Does the error mentioned follows a Stack trace? If so, can you please paste it here?

61soldiers commented 3 years ago

No, i passed in the error object as you can see from the code up there, it logs this

image

It just outputs MODULE_NOT_FOUND

JVKdouk commented 3 years ago

Reinstalling Node fixes your problem? If not, trying reinstalling your node_modules please!

JVKdouk commented 3 years ago

https://stackoverflow.com/questions/37994441/how-to-use-fs-module-inside-electron-atom-webpack-application

I found this. It may be helpful for Electron apps. I won't be able to check it right now, I believe I will try this solution over the week.

61soldiers commented 3 years ago

Don't think that will be helpful as i'm converting in the main process, anyways thanks for looking into it. I reinstalled ( Updated ) to the latest node 12 version ( as node 14 has breaking changes ) and reinstalled node_modules as you said, didn't work. Same error. Could be a problem with webpack but i'm not sure since the file is being converted in the backend ( main process ).

JVKdouk commented 3 years ago

So, just dug a bit here and the problem is a little deeper than a initially thought. Node workers doesn't work natively in electron apps and the path system breaks with the latest version of it. I will need some more time to make a fix for it a probably use background workers instead for Chromium.