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/youtube-dl/lib/youtube-dl.js 1:16-40
Module not found: Error: Cannot resolve module ‘child_process’ in /WebDev/onlyou/node_modules/youtube-dl/lib
@ ./
ERROR in .//youtube-dl/lib/youtube-dl.js/youtube-dl/lib/youtube-dl.js 2:16-29
Module not found: Error: Cannot resolve module ‘fs’ in /WebDev/onlyou/node_modules/youtube-dl/lib
@ ./
ERROR in .//tough-cookie/lib/cookie.js/tough-cookie/lib/cookie.js 32:10-24
Module not found: Error: Cannot resolve module ‘net’ in /WebDev/onlyou/node_modules/tough-cookie/lib
@ ./
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.