saadq / node-latex

🧾 A utility for running LaTeX subprocesses in Node.
MIT License
58 stars 22 forks source link

Unable to run pdfLatex #10

Closed jamesqquick closed 6 years ago

jamesqquick commented 6 years ago

I've copied over the simple example from the repo, and tried to run it but I get an unhandled 'error' each time. Not getting insightful feedback from this, so not sure how to debug...


events.js:163
      throw er; // Unhandled 'error' event
      ^

Error: Error: Unable to run pdflatex command.
    at ChildProcess.tex.on (/Users/jamesquick/Desktop/latex-sample/node_modules/node-latex/index.js:146:22)
    at emitOne (events.js:96:13)
    at ChildProcess.emit (events.js:191:7)
    at Process.ChildProcess._handle.onexit (internal/child_process.js:213:12)
    at onErrorNT (internal/child_process.js:367:16)
    at _combinedTickCallback (internal/process/next_tick.js:80:11)
    at process._tickCallback (internal/process/next_tick.js:104:9)
saadq commented 6 years ago

Do you have latex installed on your computer? Meaning if you open up a terminal and type in pdflatex --version, do you get any output?

jamesqquick commented 6 years ago

Thanks for the quick response. I do not have that installed. I didn't see that as a requirement in the ReadMe. Is there a recommended way to install?

jamesqquick commented 6 years ago

Ok got rid of that error by doing an install of Latex. didn't realize that was a separate thing to install. It's also surprisingly big, oh well. I'm going to do a pull request and add a line to readme to install.

Thanks again!

racetrack0616 commented 3 years ago

Even if I have latex installed in my local machine. I am having same issue.

saadq commented 3 years ago

Potentially a PATH issue then? Are you able to run pdflatex from your terminal?

firmprojects commented 3 years ago

I have install latex and able to run the pdflatex command. But I still get the error: Error: Error: Unable to run pdflatex command.

MiKTeX-pdfTeX 4.6.1 (MiKTeX 21.6) © 1982 D. E. Knuth, © 1996-2021 Hàn Thế Thành TeX is a trademark of the American Mathematical Society. using bzip2 version 1.0.8, 13-Jul-2019 compiled with curl version 7.72.0; using libcurl/7.72.0 Schannel compiled with expat version 2.2.10; using expat_2.2.10 compiled with jpeg version 9.4 compiled with liblzma version 50020052; using 50020052 compiled with libpng version 1.6.37; using 1.6.37 compiled with libressl version LibreSSL 3.1.4; using LibreSSL 3.1.4 compiled with MiKTeX Application Framework version 4.1.1; using 4.1.1 compiled with MiKTeX Core version 4.6; using 4.6 compiled with MiKTeX Archive Extractor version 4.0; using 4.0 compiled with MiKTeX Package Manager version 4.3; using 4.3 compiled with uriparser version 0.9.4 compiled with xpdf version 4.02 compiled with zlib version 1.2.11; using 1.2.11

saadq commented 3 years ago

In your terminal, can you type which pdflatex and see what path is printed?

And then can you try passing the entire path to the latex function options.

const input = fs.createReadStream('input.tex')
const output = fs.createWriteStream('output.pdf')

const pdf = latex(input, {
  cmd: '/path/to/pdflatex'
})

pdf.pipe(output)
pdf.on('error', err => console.error(err))
pdf.on('finish', () => console.log('PDF generated!'))
firmprojects commented 3 years ago

Okay. Will try this

On Sat, Aug 7, 2021 at 7:39 PM Saad Quadri @.***> wrote:

Can you type which pdflatex and see what path is printed?

And then can you try passing the entire path to the latex function options.

const input = fs.createReadStream('input.tex') const output = fs.createWriteStream('output.pdf')

const pdf = latex(input, { cmd: '/path/to/pdflatex' })

pdf.pipe(output) pdf.on('error', err => console.error(err)) pdf.on('finish', () => console.log('PDF generated!'))

— You are receiving this because you commented. Reply to this email directly, view it on GitHub https://github.com/saadq/node-latex/issues/10#issuecomment-894691440, or unsubscribe https://github.com/notifications/unsubscribe-auth/APYTGZA5JCQ7JF5SN6UZUSLT3V4X5ANCNFSM4EC5DFDQ . Triage notifications on the go with GitHub Mobile for iOS https://apps.apple.com/app/apple-store/id1477376905?ct=notification-email&mt=8&pt=524675 or Android https://play.google.com/store/apps/details?id=com.github.android&utm_campaign=notification-email .

bajpai123 commented 1 year ago

it still giving me error

const createNewPdf = await new Promise((resolve, reject) => { const input = fs.createReadStream(path.join(dirname + "/../latex/pledge.tex")); const output = fs.createWriteStream(path.join(dirname + "/../latex/output.pdf")); const pdf = latex(input, { cmd: "/usr/bin/pdflatex", inputs: path.join(__dirname + "/../latex/"), }); pdf.pipe(output); pdf.on("error", (err) => { console.log(err); logger.error("Pocket services v2", "upload to s3 inside promise", err); reject(false); }); pdf.on("finish", () => { logger.info("Pocket services v2", "upload to s3", "File Created"); resolve(true); }); });