vendredi 27 août 2021

Problem when loading child_process into Javascript

I'm trying to start a child process in Javascript to run a Python script in background, this is the code that I use:

var spawn = require(["child_process"]).spawn;
var process = spawn('python',["main.py"]);

And this is the error that appears in the console:
Uncaught ReferenceError: primordials is not defined

I had to import this script into my html file to make require function work:

<script src="https://requirejs.org/docs/release/2.3.6/r.js"></script>

I would like to find a solution for this problem.




Aucun commentaire:

Enregistrer un commentaire