0

I was looking for a way to run node js from python and I found naked and it has really solved my issue. I however have a quick question whose answer I have not been able to find anywhere on the net. So this is what i am trying to do:

I want to run a file 'test.js' with javascript function that takes the argument message

i.e

function run_test(message){

   // some code   
}

the argument message however has come come from the python side of things so how do i pass arguments from python and use them in my run_test function 
I found this method:

if len(arguments) > 0:
            js_command = file_path + " " + arguments
        else:
            js_command = file_path

So how can a get the arguments passed from python and use them in my run_test function in javascript

2

1 Answer 1

1

I think that you already found the solution but for those who is searching, process.argv is the answer which is an array where first 2 elements are node command and path to your script which you can skip.

So, in JS you should have const arguments = process.argv.slice(2)

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

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.