rannn505 / child-shell

Node.js bindings 🔗 for shell
http://rannn505.github.io/child-shell/
MIT License
299 stars 71 forks source link

TypeError: shell is not a constructor #144

Open baba20o opened 2 years ago

baba20o commented 2 years ago

Hi,

I have been trying to use node-powershell and I constantly get this error

"TypeError: shell is not a constructor"

I have installed it on multiple machines, different folders, etc and it all brings back the same error message

pserror

here is the sample code I'm using to test

var shell = require('node-powershell'); var ps = new shell({executionPolicy: 'Bypass', debugMsg: true, noProfile: true}); ps.addCommand('echo "node-powershell rocks"') .then(function(){ return ps.invoke(); }) .then(function(output){ console.log(output); ps.dispose(); }) .catch(function(err){ console.log(err); ps.dispose(); });

cuchulopez commented 2 years ago

Hi, I have the same problem.

imagen

Saludos.

cuchulopez commented 2 years ago

I was able to fix it. imagen

ZTechGuy commented 2 years ago

I'm also experiencing this issue, and the fixes previously mentioned (in this thread and in issue #16 ) are not working for me. Has anyone else found a solution?

baba20o commented 2 years ago

For me I just had to go back to an old version and it just works in that way.

From: ZTechGuy @.> Sent: Tuesday, July 19, 2022 8:16 AM To: rannn505/child-shell @.> Cc: jonkindheaven @.>; Author @.> Subject: Re: [rannn505/child-shell] TypeError: shell is not a constructor (Issue #144)

I'm also experiencing this issue, and the fixes previously mentioned (in this thread and in issue #16 https://github.com/rannn505/child-shell/issues/16 ) are not working for me. Has anyone else found a solution?

— Reply to this email directly, view it on GitHub https://github.com/rannn505/child-shell/issues/144#issuecomment-1188978529 , or unsubscribe https://github.com/notifications/unsubscribe-auth/AKE5C6EUMN5SV3SB4QO4TMDVU2L6FANCNFSM5IULHEMA . You are receiving this because you authored the thread. https://github.com/notifications/beacon/AKE5C6CYU4YEPGYBMTM37E3VU2L6FA5CNFSM5IULHEMKYY3PNVWWK3TUL52HS4DFVREXG43VMVBW63LNMVXHJKTDN5WW2ZLOORPWSZGOI3PF6YI.gif Message ID: @. @.> >

rzfzr commented 2 years ago

@jonkindheaven what version you went back to?

msdiniz commented 1 year ago

I

For me I just had to go back to an old version and it just works in that way. From: ZTechGuy @.> Sent: Tuesday, July 19, 2022 8:16 AM To: rannn505/child-shell @.> Cc: jonkindheaven @.>; Author @.> Subject: Re: [rannn505/child-shell] TypeError: shell is not a constructor (Issue #144) I'm also experiencing this issue, and the fixes previously mentioned (in this thread and in issue #16 <#16> ) are not working for me. Has anyone else found a solution? — Reply to this email directly, view it on GitHub <#144 (comment)> , or unsubscribe https://github.com/notifications/unsubscribe-auth/AKE5C6EUMN5SV3SB4QO4TMDVU2L6FANCNFSM5IULHEMA . You are receiving this because you authored the thread. https://github.com/notifications/beacon/AKE5C6CYU4YEPGYBMTM37E3VU2L6FA5CNFSM5IULHEMKYY3PNVWWK3TUL52HS4DFVREXG43VMVBW63LNMVXHJKTDN5WW2ZLOORPWSZGOI3PF6YI.gif Message ID: @. @.> >

Me too. To fix, explicitly I did:

const ps = new Shell({ // error ^ TypeError: Shell is not a constructor with "node-powershell": "^5.0.1", // FIXED !!! it works flawless with "node-powershell": "^4.0.0",

jasonmacer commented 1 year ago

Just as a bump on this issue...

I was running ~5.0.1 and getting the same error as everyone above. I downgraded like @msdiniz suggested and that fixed my error.

I'm guessing there is something that was changed in versions over 4.0.0.

🤷🏼‍♂️