Module not found: "child process"

I am developing a ReactJS application with Babel and Webpack. I use facebook to create a reaction-application script, so it handles the Webpack configuration. My problem is that I created a js file and added:

var childProcess = require('child_process');

But when I want to compile the new version, I get the following error:

Module not found: 'child_process'.

I don’t know what to do with it. I read that adding custom configurations to webpack.config.js may be a solution, but I am using the application to create a reaction, so I don't have a Webpack configuration. I tried to run npm run eject and create my own webpack.config.js, but it does not work.

I hope someone can help me.

+4
1

target webpack: https://webpack.imtqy.com/docs/configuration.html#target

module.exports = {
  entry: './path/to/my/entry/file.js',
  ...
  target: 'node',// we can use node.js modules after adding this configuration
};
+3

Source: https://habr.com/ru/post/1672699/


All Articles