I have a BeginTestView.vue page that has a start testing button. Clicking this button launches an exe file with Nunit tests in C# . I want to run the exe using child_process execFile in the Vue component. I get the error Module not found: Error: Can’t resolve ‘child_process’ in With:…….
However, if you run this exe file from the main process when launching the application, everything works fine. How can I use child_process in vuejs itself?
I tried to run the exe file using child_process in the vue component, but I get the error Module not found: Error: Can’t resolve ‘child_process’ in ‘C:…..
Sample code:
<script setup>
//import { execFile } from 'child_process'
function beginTest(){
const execFile = require('child_process')
execFile("./testexe/TestConsole.exe", (error, stdout, stderr) => {
if (error) {
console.error(`Error executing the file: ${error.message} dirname:${__dirname}`);
return;
}
console.log(`File executed successfully: ${stdout}`);
});
}
</script>
<template>
<div class="content">
<button class="button" @click="beginTest">Begin test</button>
</div>
</template>
<style scoped lang="scss">
...
</style>