Webpack: Cannot resolve module 'child_process' , 'fs' , 'net' - youtube-dl with webpack

Created on 5 Mar 2016  路  3Comments  路  Source: webpack/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

question

Most helpful comment

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.

All 3 comments

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.

Get some error -- "Uncaught ReferenceError: require is not defined"

screen shot 2016-03-11 at 4 05 12 pm

I have found solution like this
http://jlongster.com/Backend-Apps-with-Webpack--Part-II

Thanks @taurose for respond

Was this page helpful?
0 / 5 - 0 ratings