0

I have written below code to execute powershell script from typescipt page. I can read the script output at run time using node.js But when I use the same code in react framework app (client side typescript) page, I'm getting error in browser console.

spawn is not a function

var spawn = require("child_process").spawn;
spawn("powershell.exe",[".\download-packages-license.ps1"]);

How to execute powershellscript at run time from the client side typescript react app?

1 Answer 1

1

You can not execute PowerShell from a browser. The thing you are trying to do is Node.js code, but the browser is not the same thing as Node.js and therefore it does not have these functions and capabilities.

Browser code doesn't even have an access to the file system.

Sign up to request clarification or add additional context in comments.

2 Comments

yes ,Is there any way to execute powershell from a browser code?
If you can have the Node.js HTTP server running on the Client then you may workaround it. But the thing is if you are serving the WebSite you cannot do that. So the answer is no.

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge you have read our privacy policy.

Start asking to get answers

Find the answer to your question by asking.

Ask question

Explore related questions

See similar questions with these tags.