I tried to implement some basic stuff, like get MachineName and Private and Public IP address through Node using node-powershell, and it is running without issues in Windows with Powershell 7.3.1.
Part of the working code is:
const Shell = require('node-powershell');
const os = require('os');
async function getMachineName () {
let name = null;
let error = null;
let cmd;
if (os.platform() === 'linux') {
cmd = 'hostname';
} else {
cmd = '$Env:Computername';
}
await Shell.PowerShell.$`${cmd}`
.then(response => {
console.log(response.raw);
name = response.raw.replaceAll('[?1h[?1l', '').trim();
})
.catch(err => {
console.log(err);
error = err;
});
return { name, error };
}
module.exports = { getMachineName };
I tried the same in Ubuntu 22.04 - same powershell version - and the very same function(s) are all always ending in:
ProcessError: Shell process 118990 exited.
undefined
at /home/marcelo/repos/child-shell-test/packages/child-shell/lib/Shell.ts:232:15
at processTicksAndRejections (node:internal/process/task_queues:95:5) {
originalError: undefined,
exitCode: null,
signalCode: 'SIGABRT'
}
only changing the PID, of course.
So, I forked and installed child-shell playground, installed it in both Windows and Ubuntu machines and to my surprise, both ended in error at same spots:
I tried to implement some basic stuff, like get MachineName and Private and Public IP address through Node using node-powershell, and it is running without issues in Windows with Powershell 7.3.1.
Part of the working code is:
I tried the same in Ubuntu 22.04 - same powershell version - and the very same function(s) are all always ending in:
only changing the PID, of course.
So, I forked and installed child-shell playground, installed it in both Windows and Ubuntu machines and to my surprise, both ended in error at same spots:
There are few differences though: 1) Windows log is much less verbose 2) Windows error msg says that signalCode: null, instead of 'SIGABRT'
I have the last nvm in both machines and tested all these node versions: v14.21.2 v16.14.2 v16.15.0 -> v18.12.1 v19.3.0
Any clues how to address this?