import { exec } from "child_process";
I am having a problem with using child_process in Angular 15. I always get this error:
ERROR in src/app/gerfactory/gerfactory.component.ts:6:22 - error TS2307: Cannot find module 'child_process' or its corresponding type declarations.
I installed it by typing npm i child_process
, but whenever I try to call it in my Angular application, I get the error message above.
This is the function I wrote that needs to use {exec}
from "child_process"
:
async runMiddleWare(path: string){
exec(path, (error, stdout, stderr) =>{
if (error) {
console.error(`Error executing software: ${error.message}`);
return;
}
if (stderr) {
console.error(`Software error: ${stderr}`);
return;
}
console.log(`Software output: ${stdout}`);
});
}
UPDATE: Just now I discovered child_process
was removed from the npm (see here on npmjs.com). However, I need my front-end application to be able to call a software in my local computer, since this is how the client wants it to work (go figure). Does anyone know how to do it?