I'm trying to run a node js script from my main.py file in which there are other functions from different files. My main goal is that in one main.py file to run all the functions that I need for my application. I tried to use js2py but it crashed with an error:
raise Ecma51NotSupported('ArrowFunctionExpression')
pyjsparser.std_nodes.Ecma51NotSupported: ArrowFunctionExpression is not supported by ECMA 5.1.
I have also tried to use Naked but that also crashed.
I don't need any data from this node js file or anything just to run either all script or one function that it has.
In best case scenario it would work just like with .py files:
from python_file import do_some_work
do_some_work()
Any suggestions or fix ?
The error is quite clear, you're using arrow functions ((param) => expression) which are not supported in ECMAScript 5 standard, which is the one used by defualt in js2py.
According to the author, latest versions now support ES6 evaluation by using eval_js6 (source).
So it's either removing the arrow functions and sticking to ES5 or trying this function to run the code.
Running whole node js script from main.py using
import os and
os.system('node file.js') did the job!