Business
Jobs
  • About Us
  • Solutions
    • Job Postings
      Post your job and receive qualified candidates in 48h.
    • Candidate Assessments
      500+ technical and psychological tests, plus anti-fraud.
    • Headhunting
      Tailor-made executive search from start to finish.
    • Payroll + EOR
      Payroll dispersal and EOR across 15+ LATAM countries.
  • Pricing
  • Jobs

0

869
Views
Error: generar ENOENT html-pdf nodejs en el servidor

Tengo un problema al crear pdf usando html-pdf. En mi local funciona bien pero en el servidor no funciona. mi código a continuación:

 const fileName = './public/offering/' + dayjs().format('YYYY-MM-DD') + '-' + name[0] + '.pdf'; const htmlToPdfOptions = { type: 'PDF', height: '1200px', width: '816px', renderDelay: 2000, format: 'Letter', phantomPath: require('requireg')('phantomjs-prebuilt').path, }; pdf.create(file, htmlToPdfOptions).toFile(fileName, async function (err: any, result: any) { if (err) return console.log(err, 'xxxxxxxxxxxxxx this error'); console.log(result) });

en mi ventana acoplable así

 FROM node:14-alpine RUN npm install --global pm2 RUN mkdir -p /usr/src/app WORKDIR /usr/src/app COPY . . COPY package*.json ./ COPY . . RUN npm install && npm run build RUN npm install -g phantomjs --unsafe-perm COPY . . EXPOSE 8500 CMD ["pm2-runtime", "start", "src/index.js"]

El error en el servidor es

 Error: spawn /usr/src/app/node_modules/phantomjs-prebuilt/lib/phantom/bin/phantomjs ENOENT at Process.ChildProcess._handle.onexit (internal/child_process.js:269:19) at onErrorNT (internal/child_process.js:467:16) at processTicksAndRejections (internal/process/task_queues.js:82:21) { errno: -2, code: 'ENOENT', syscall: 'spawn /usr/src/app/node_modules/phantomjs-prebuilt/lib/phantom/bin/phantomjs', path: '/usr/src/app/node_modules/phantomjs-prebuilt/lib/phantom/bin/phantomjs', spawnargs: [ '--local-url-access=false', '/usr/src/app/node_modules/html-pdf/lib/scripts/pdf_a4_portrait.js' ] }

¿Alguien puede ayudarme? porque ya probé algunas soluciones en la web pero nada funciona o alguien me puede dar referencia?. ejemplo: Nodejs + PhantomJS en Docker: Error: spawn - ENOENT

about 4 years ago · Juan Pablo Isaza
1 answers
Answer question

0

Su Dockerfile tiene algunos comandos de copia extraños. Esto debería solucionar tu problema

 FROM node:14-alpine RUN npm install --global pm2 RUN mkdir -p /usr/src/app WORKDIR /usr/src/app COPY . . RUN npm install && npm run build RUN npm install -g phantomjs --unsafe-perm EXPOSE 8500 CMD ["pm2-runtime", "start", "src/index.js"]

También debe agregar node_modules a su archivo .dockerignore .

about 4 years ago · Juan Pablo Isaza Report
Answer question
Find remote jobs

Discover the new way to find a job!

Top jobs
Top job categories
Business
Post vacancy Pricing Sales
Legal
Terms and conditions Privacy policy
© 2026 PeakU Inc. All Rights Reserved.
Andres GPT
Show me some job opportunities
There's an error!