Run js command with Symfony's Component Process

677 Views Asked by At

I want to run npm-like commands with Symfony's Component Process. The actual command is relaxed htmlFile.html. The command works when I run it with CLI, but when I run it with Process I get the error below.

The command "node -v" failed. Exit Code: 1(General error) Working directory: C:\xampp\pro-resume\public Output: ================ Error Output: ================ 'node' is not recognized as an internal or external command, operable program or batch file.

I'm using a library called relaxed.js to convert HTML files to PDF.

In this example, I tried to run node -v.

$process = new Process(['node', '-v']);
$process->mustRun();
echo $process->getOutput();

if (!$process->isSuccessful()) {
   throw new ProcessFailedException($process);
}

The env is Xampp server on Windows. Laravel 9, php 8.

0

There are 0 best solutions below