1

I have a web application and on button click I want to run node command. Instead of executing node command on command line, trying to execute it on click of button from front end. ex:- I have a web application and on button click I want to run node command. Instead of executing node command on command line, trying to execute it on click of button from front end.

ex:

$( ".button_class" ).on( "click", function() {
   //execute command like : node app.js
 });

2 Answers 2

5

You can not run node command line on client side as you mention. But alternatively you can make api and hit that api on button click. In that api you can run commnad with.

I am giving you link. that can help you to run command line with node.

https://www.npmjs.com/package/node-cmd

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

Comments

1

Use the package called node-cmd, install it with npm npm i node-cmd. Documentation link: Documentation

Comments

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.