Cannot resolve module ‘child_process’ , ‘fs’ , ‘net’ – youtube-dl with webpack

Hello everyone
i just couldn’t set up webpack and youtube-dl and some other modules like shelljs

if i run in terminal “node my_Youtube_dl_Script.js” it wokrs fine
but with webpack does not

i know what youtube-dl require the child_process,fs,net
and youtube-dl not supporting browser environment
but even if i pass the in package.json

"browser": {
"net": false,
"fs": false,
"child_process":false

},

it otherwise ask about Cannot resolve module
so it dosent reslove my issue

webpack working with modules fs, child_process, net, ?
or it does not?
how can i add child_process,fs,net modules to webpack?
or how can i run youtube-dl out of webpack ?
maybe with shelljs?


ERROR in .//youtube-dl/lib/youtube-dl.js
Module not found: Error: Cannot resolve module ‘child_process’ in /WebDev/onlyou/node_modules/youtube-dl/lib
@ ./
/youtube-dl/lib/youtube-dl.js 1:16-40

ERROR in .//youtube-dl/lib/youtube-dl.js
Module not found: Error: Cannot resolve module ‘fs’ in /WebDev/onlyou/node_modules/youtube-dl/lib
@ ./
/youtube-dl/lib/youtube-dl.js 2:16-29

ERROR in .//tough-cookie/lib/cookie.js
Module not found: Error: Cannot resolve module ‘net’ in /WebDev/onlyou/node_modules/tough-cookie/lib
@ ./
/tough-cookie/lib/cookie.js 32:10-24

Author: Fantashit

1 thought on “Cannot resolve module ‘child_process’ , ‘fs’ , ‘net’ – youtube-dl with webpack

  1. You can set target: 'node' in your webpack.config file (docs). This should get rid of the node API errors and leave the require calls inside your bundle.

    It might be better to just leave the dependencies out of your bundle like you mentioned, since you might run into other problems like dynamic requires. There’s a plugin that does this.

Comments are closed.