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

143
Views
Node.js exec para construir las rebajas de Marp no funciona

Escribí este script simple de node.js para crear el descuento de Marp y convertirlo a PDF. Pero no hace nada y no termina. Agregué un archivo console.log console.log("test") al final. Veo que node.js no espera a que finalicen todas las ejecuciones de comandos, pero exec tampoco ejecuta el comando de compilación Marp.

Si ejecuto la cadena "cmd" desde la terminal, todo funciona. Creo que algo anda mal con la forma en que uso exec

 var glob = require("glob"); var cp = require("child_process"); glob("lab*/*.marp.md", {}, function (err, files) { files.forEach((file) => { var destination = file.replace(".md", ""); var cmd = `marp ${file} --allow-local-files --pdf -o ${destination}.pdf`; var dir = cp.exec(cmd, (err, stdout, stderr) => { if (err) { console.log("node couldn't execute the command"); return; } // the *entire* stdout and stderr (buffered) console.log(`stdout: ${stdout}`); console.log(`stderr: ${stderr}`); }); dir.on("exit", function (code) { // exit code is code console.log(`finished building: ${file}`); }); }); });
about 4 years ago · Juan Pablo Isaza
1 answers
Answer question

0

puedes probar la función execSync(). Resolverá el problema.

 var glob = require("glob"); var cp = require("child_process"); glob("lab*/*.marp.md", {}, function (err, files) { files.forEach((file) => { var destination = file.replace(".md", ""); var cmd = `marp ${file} --allow-local-files --pdf -o ${destination}.pdf`; var dir = cp.execSync(cmd, (err, stdout, stderr) => { if (err) { console.log("node couldn't execute the command"); return; } // the *entire* stdout and stderr (buffered) console.log(`stdout: ${stdout}`); console.log(`stderr: ${stderr}`); }); dir.on("exit", function (code) { // exit code is code console.log(`finished building: ${file}`); }); }); });
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!