I'm trying to run the following code in Vue.js CLI project, which executes a python file by using Python-shell (node-module):
methods: {
launchPy() {
let {PythonShell} = require('python-shell')
PythonShell.run('my_script.py', null, function (err) {
if (err) throw err;
console.log('finished2');
});
},
In the 'my_script.py', the following code was inserted:
f = open("demo.txt", "a")
f.write("Writing a file")
f.close()
When I run the localhost and execute the method from a botton click: launchPy(), the next error appears:
[Vue warn]: Error in v-on handler: "TypeError: child_process_1.spawn is not a function"
I have installed node.js and Python-shell already. Even when I run the exact same code of function launchPy() in a separate fileName.js file and execute the 'node fileName.js' command, it runs smoothly and indeed, the python file is executed.
How can I resolve this issue?