rse / node-prince

Node API for executing PrinceXML via prince(1) CLI
https://npmjs.com/prince
49 stars 24 forks source link

princexml wasn't found in path #52

Open GetPsyched opened 1 year ago

GetPsyched commented 1 year ago

When I run my application that uses node-prince as a dependency, it errors out saying Error: Prince#execute: cannot resolve binary "prince" to a filesystem path

Full error:

Error: Prince#execute: cannot resolve binary "prince" to a filesystem path
    at Prince._execute (/home/getpsyched/git/printer/node_modules/prince/prince-api.js:292:19)
    at Prince.execute (/home/getpsyched/git/printer/node_modules/prince/prince-api.js:359:17)
    at generatePDF (file:///home/getpsyched/git/printer/build/server/chunks/generate-012b0792.js:30:106)
    at async POST (file:///home/getpsyched/git/printer/build/server/chunks/_server.ts-b6de181a.js:8:15)
    at async render_endpoint (file:///home/getpsyched/git/printer/build/server/index.js:1575:20)
    at async resolve (file:///home/getpsyched/git/printer/build/server/index.js:4002:22)
    at async respond (file:///home/getpsyched/git/printer/build/server/index.js:3891:22)
    at async Array.ssr (file:///home/getpsyched/git/printer/build/handler.js:1221:3)
GetPsyched commented 1 year ago

I am on NixOS

rse commented 1 year ago

Well, it means that "prince" is not in $PATH and that node-prince was also unable to determine that NixOS is a Linux environment. So, either you have to install PrinceXML manually into the system before using node-prince or we have to figure out what check is needed to recognize NixOS in https://github.com/rse/node-prince/blob/master/prince-npm.js

GetPsyched commented 1 year ago

I have installed PrinceXML manually on my system but I was having issues doing the same on the deployed instance of my application (which also runs it on NixOS AFAIK).

or we have to figure out what check is needed to recognize NixOS in https://github.com/rse/node-prince/blob/master/prince-npm.js

How can I help with that? I'm willing to do some debugging if you wish.

GetPsyched commented 1 year ago

I just cloned this repo and ran npm install. Here's the logs: image

It actually does detect NixOS as a Linux environment and chooses the correct package. But it does not do this when using node-prince as a dependency.

GetPsyched commented 1 year ago

@rse any comment?

rse commented 11 months ago

I've tried it out: I've created a package.json with a dependency to "prince" and then have run...

npm --loglevel=silly i --foreground-scripts

...(with NPM 10.2.3) and the "install" script was correctly executed inside the "prince" package (it downloaded PrinceXML and unpacked it). So, perhaps it is an issue with your particular/older NPM version?

GetPsyched commented 11 months ago

I'm getting a new error after updating prince to 1.11.1:

Error: {"error":{"errno":-2,"code":"ENOENT","syscall":"spawn /home/getpsyched/git/printer/node_modules/prince/prince/lib/prince/bin/prince","path":"/home/getpsyched/git/printer/node_modules/prince/prince/lib/prince/bin/prince","spawnargs":["--prefix","/home/getpsyched/git/printer/node_modules/prince/prince/lib/prince","dist/question-paper.html","--output","dist/output.pdf"],"cmd":"/home/getpsyched/git/printer/node_modules/prince/prince/lib/prince/bin/prince --prefix /home/getpsyched/git/printer/node_modules/prince/prince/lib/prince dist/question-paper.html --output dist/output.pdf"},"stdout":{"type":"Buffer","data":[]},"stderr":{"type":"Buffer","data":[]}}
    at Module.coalesce_to_error (/home/getpsyched/git/printer/node_modules/@sveltejs/kit/src/utils/error.js:9:5)
    at Module.handle_fatal_error (/home/getpsyched/git/printer/node_modules/@sveltejs/kit/src/runtime/server/utils.js:72:47)
    at resolve (/home/getpsyched/git/printer/node_modules/@sveltejs/kit/src/runtime/server/respond.js:500:17)
    at process.processTicksAndRejections (node:internal/process/task_queues:95:5)
    at async Module.respond (/home/getpsyched/git/printer/node_modules/@sveltejs/kit/src/runtime/server/respond.js:274:20)
    at async file:///home/getpsyched/git/printer/node_modules/@sveltejs/kit/src/exports/vite/dev/index.js:510:22

Note that I do find the binary installed by the lib at the relative path: node_modules/prince/prince/lib/prince/bin/prince