I officially give up. I'm trying to run a node es6 project that uses es6 import syntax, but the child processes won't work. The problem is that childprocess.fork uses node and not babel-node. I've gotten it to run using babel-node, but now they can't communicate via process.send. I'm looking for any options to solve the problem, maybe there is an easier one.
let appPath = path.dirname(require.main.filename);
let babelPath = path.join(appPath, 'node_modules/.bin/babel-node.cmd'); //WINDOWS
let filepath = path.join(__dirname, 'processes', moduleName);
let process = childProcess.fork(filepath, { execPath: babelPath });
process.on('message', msg => console.log(msg));
which gives me this:
Error: channel closed at ChildProcess.target.send (internal/child_process.js:523:16)
Babel CLI page says:
You should not be using
babel-node
in production.
Instead, compile all the files first, and then run childProcess.fork()
on the compiled files.
Collected from the Internet
Please contact [email protected] to delete if infringement.
Comments