Node-bunyan: Breaks browserify bundle w/o `source-map-support` installed

Created on 28 Jan 2015  路  16Comments  路  Source: trentm/node-bunyan

In this commit a require was added for source-map-support here.

However, despite the try catch check this will break with browserify as it inspects the js and tries to resolve the require and create the require with the following error:

Error: Cannot find module 'source-map-support' from '/Users/efuquen/Code/test/browserify-test/node_modules/bunyan/lib'

Most helpful comment

It seems that this is broken when one is trying to bundle it with webpack. I am just starting to learn about webpack and have been using browserify before, but when I try to pack a library of mine that uses bunyan into a working react app I get this while bundling:

WARNING in ./~/figo-to-ynab/~/bunyan/lib/bunyan.js
Module not found: Error: Cannot resolve module 'source-map-support' in /home/levin/WebstormProjects/react-hot-boilerplate/node_modules/figo-to-ynab/node_modules/bunyan/lib
 @ ./~/figo-to-ynab/~/bunyan/lib/bunyan.js 106:27-61

Using [email protected]

All 16 comments

I am running into this issue as well and don't have time to create a proper PR.

also seeing this.

@efuquen @olsonpm @chmontgomery Any of you able to try out the latest commit (no published version in npm yet) to see if that fixes the issue? I don't use browserify to really test it well.

I should be able to tomorrow. Thanks for addressing it

@trentm - tried just now and couldn't reproduce it even with npm's version. I then checked and it looks like you published a release to npm yesterday. I'll assume you pushed the fix out.

So, works on my end.

@olsonpm thanks! Sorry about the release adding confusion (it was for a separate fix).

It seems that this is broken when one is trying to bundle it with webpack. I am just starting to learn about webpack and have been using browserify before, but when I try to pack a library of mine that uses bunyan into a working react app I get this while bundling:

WARNING in ./~/figo-to-ynab/~/bunyan/lib/bunyan.js
Module not found: Error: Cannot resolve module 'source-map-support' in /home/levin/WebstormProjects/react-hot-boilerplate/node_modules/figo-to-ynab/node_modules/bunyan/lib
 @ ./~/figo-to-ynab/~/bunyan/lib/bunyan.js 106:27-61

Using [email protected]

We ran into this as well with Webpack. We're pegged to bunyan 1.8.1 and things are working again.

=( Using 1.8.1 with Webpack and getting the error

This is still an issue with webpack

+1 same error with webpack

still an issue with Angular2 which has webpack integrated by default.

馃憤 similar issue,

"webpack": "^3.5.4"
[1] [0] WARNING in ./node_modules/bunyan/lib/bunyan.js
[1] [0] Module not found: Error: Can't resolve 'source-map-support' in '.../backend/node_modules/bunyan/lib'
[1] [0]  @ ./node_modules/bunyan/lib/bunyan.js 106:27-61
[1] [0]  @ ./src/utils/logger/logger.js
[1] [0]  @ ./src/utils/logger/index.js
[1] [0]  @ ./src/utils/connector/Connector.js
[1] [0]  @ ./src/api-routes/deliveryServiceRoutes.js
[1] [0]  @ ./src/api-routes/index.js
[1] [0]  @ ./src/app.js
[1] [0]  @ ./src/index.js
[1] [0]  @ multi ./src/index

For webpack, configure it to ignore those deps per readme:

noParse: [/dtrace-provider/, /safe-json-stringify/, /mv/, /source-map-support/]

@mrchief interesting, Do you need to ignore all of those for this specific problem? or will it be enough with /dtrace-provider/?

In addition I got another error Error: Cannot find module './build/Release/DTraceProviderBindings' so I am not sure how this will solve the problem,

Perhaps you can give more details why no parse the dependency will solve the need for our code to import it

@EduardoAC I'm not sure if I can answer your questions properly but I'll try. I hope a contributor/owner can pitch in here and provide some better answers. I'm going by the readme and this is my 2nd day using this module - so take my answers with that caveat. :)

I think dtrace, safe-json-stringify etc are optional dependencies. Moreover, one or more of them may not work on the browser or some envs (e.g. dtrace only works in certain OSes). So that directive simply tells webpack to not worry about it.

If your code depends on those somehow, then of course, you can't ignore them. If you have separate webpack configs to build your node bundle and browser bundle, you can try having the noparse rules only in the browser bundle and not in the node bundle. Beyond that, maybe you can explore ContextReplacementPlugin or IgnorePlugin and see if those can help your case.

Do you need to ignore all of those for this specific problem?

The first 3 are part of readme, so I'm assuming yes. The last one seems a new one (readme needs an update I guess). I haven't dug deep enough to see what those modules do, so not sure if you _should_ be ignoring them. I guess that'll depend on one's particular use case.

Was this page helpful?
0 / 5 - 0 ratings