Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Error: spawn unoconv ENOENT #1

Open
bramvanhoutte opened this issue Feb 28, 2019 · 6 comments
Open

Error: spawn unoconv ENOENT #1

bramvanhoutte opened this issue Feb 28, 2019 · 6 comments

Comments

@bramvanhoutte
Copy link

I get an error when running my implmentation (in Typescript) of the example code:

const path = require('path')
const unoconv = require('awesome-unoconv')
import * as fs from 'fs'
 
const sourceFilePath = path.resolve('./test.docx')
const outputFilePath = path.resolve('./myDoc.pdf')

unoconv
  .convert(sourceFilePath, outputFilePath)
  .then((result: any) => {
    console.log(result);
  })
  .catch((err: any) => {
    console.log(err);
  });

I get the following error:

{ Error: spawn unoconv ENOENT
    at Process.ChildProcess._handle.onexit (internal/child_process.js:246:19)
    at onErrorNT (internal/child_process.js:421:16)
    at processTicksAndRejections (internal/process/next_tick.js:76:17)
    at process.runNextTicks [as _tickCallback] (internal/process/next_tick.js:51:3)
    at Function.Module.runMain (internal/modules/cjs/loader.js:800:11)
    at executeUserCode (internal/bootstrap/node.js:526:15)
    at startMainThreadExecution (internal/bootstrap/node.js:439:3)
  errno: 'ENOENT',
  code: 'ENOENT',
  syscall: 'spawn unoconv',
  path: 'unoconv',
  spawnargs:
   [ '-f',
     'pdf',
     '--stdout',
     'C:\\Users\\beantaxbhou\\Documents\\Development\\powerpoint-to-pdf-converter\\build\\test.docx' ] }

I found that 'ENOENT' means that a file can't be found. All the files are present, so this confuses me.
Furthermore, when I run the following command in CMD unoconv -f pdf test.docx it works and creates a .pdf file without any errors. What am I missing here?

@thisromantelecom
Copy link

thisromantelecom commented Aug 12, 2019

I get an error when running my implmentation (in Typescript) of the example code:

const path = require('path')
const unoconv = require('awesome-unoconv')
import * as fs from 'fs'
 
const sourceFilePath = path.resolve('./test.docx')
const outputFilePath = path.resolve('./myDoc.pdf')

unoconv
  .convert(sourceFilePath, outputFilePath)
  .then((result: any) => {
    console.log(result);
  })
  .catch((err: any) => {
    console.log(err);
  });

I get the following error:

{ Error: spawn unoconv ENOENT
    at Process.ChildProcess._handle.onexit (internal/child_process.js:246:19)
    at onErrorNT (internal/child_process.js:421:16)
    at processTicksAndRejections (internal/process/next_tick.js:76:17)
    at process.runNextTicks [as _tickCallback] (internal/process/next_tick.js:51:3)
    at Function.Module.runMain (internal/modules/cjs/loader.js:800:11)
    at executeUserCode (internal/bootstrap/node.js:526:15)
    at startMainThreadExecution (internal/bootstrap/node.js:439:3)
  errno: 'ENOENT',
  code: 'ENOENT',
  syscall: 'spawn unoconv',
  path: 'unoconv',
  spawnargs:
   [ '-f',
     'pdf',
     '--stdout',
     'C:\\Users\\beantaxbhou\\Documents\\Development\\powerpoint-to-pdf-converter\\build\\test.docx' ] }

I found that 'ENOENT' means that a file can't be found. All the files are present, so this confuses me.
Furthermore, when I run the following command in CMD unoconv -f pdf test.docx it works and creates a .pdf file without any errors. What am I missing here?

unoconv command not found in System paths

@weihsth
Copy link

weihsth commented Jun 12, 2020

I have the same issue. I downloaded "unoconv-0.8.2" zip, and unpacked it to "C:\dev\unoconv-0.8.2". Windows 10 "Path" Variable ends with ";D:\Libre Office\program;C:\dev\unoconv-0.8.2;"

But "awesome-unoconf" still throws error:

unoconv command not found
{ Error: spawn unoconv ENOENT
at Process.ChildProcess._handle.onexit (internal/child_process.js:240:19)
at onErrorNT (internal/child_process.js:415:16)
at process._tickCallback (internal/process/next_tick.js:63:19)
errno: 'ENOENT',
code: 'ENOENT',
syscall: 'spawn unoconv',
path: 'unoconv',
spawnargs:
[ '-f',
'pdf',
'--stdout',
'C:\solutions\up2boat-api\output.docx' ] }

@Zigonja
Copy link

Zigonja commented Sep 30, 2020

Same issue here

@vik17ag
Copy link

vik17ag commented Nov 18, 2020

same issue

@suthishan
Copy link

same issue

unoconv command not found Error: spawn unoconv ENOENT at Process.ChildProcess._handle.onexit (node:internal/child_process:282:19) at onErrorNT (node:internal/child_process:477:16) at processTicksAndRejections (node:internal/process/task_queues:83:21) { errno: -4058, code: 'ENOENT', syscall: 'spawn unoconv', path: 'unoconv',

@jovi920204
Copy link

Hi everyone,

I'm encountering an error and I'm not entirely sure what caused it. However, I've found a solution that might work for you too.

Firstly, I downloaded the unoconv.zip package from github.com/unoconv/unoconv and the latest version of LibreOffice from the LibreOffice website.

Secondly, I unzipped the unoconv.zip file wherever I preferred. In my case, I unzipped it to C:/Program Files (x86)/. It's worth noting that my operating system is Windows 10.

Thirdly, ensure that you can use the unoconv command normally by running python C:/Program Files (x86)/unoconv/unoconv -h. This command should display the usage of unoconv.

Finally, you need to modify the awesome-unoconv package. In the example code provided:

const path = require('path');
const unoconv = require('awesome-unoconv');

const sourceFilePath = path.resolve('./myDoc.docx');
const outputFilePath = path.resolve('./myDoc.pdf');

unoconv
  .convert(sourceFilePath, outputFilePath)
  .then(result => {
    console.log(result); // return outputFilePath
  })
  .catch(err => {
    console.log(err);
  });

Follow the unoconv.convert() function to convert.js. At lines 105 and 134, you need to add {shell: true}.
Original code:
var unoconv = (0, _child_process.spawn)('unoconv', ['-f', option.format, '--stdout', input])
After modification:
var unoconv = (0, _child_process.spawn)('unoconv', ['-f', option.format, '--stdout', input, {shell: true}])

Additionally, we need to change the command unoconv.
final code:
var unoconv = (0, _child_process.spawn)('python "C:\\Program Files (x86)\\unoconv\\unoconv"', ['-f', option.format, '--stdout', input, {shell: true}])

This solution worked for me. However, I believe there might be better debugging approaches available. Please feel free to communicate with me if you have any suggestions or if you encounter any issues.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

7 participants