How does one use a module like 'child_process' from a ReactJS app?
(react@16.3.1 / Linux)
These syntaxes fail:
import { spawn } from 'child_process'
const ls = spawn('ls', ['-al']);
yields: TypeError: Object(...) is not a function
import cp from 'child_process';
const ls = cp.spawn('ls', ['-al']);
yields: TypeError: __WEBPACK_IMPORTED_MODULE_3_child_process___default.a.spawn is not a function
var { spawn } = require('child_process');
const ls = spawn('ls', ['-al']);
yields: TypeError: spawn is not a function
You can't use node's module child_process
in a react application.
You can't access to OS system processes to spawn and fork from browser because it's an isolated environment.