I'm trying to use timbre.js (npm version) with Browserify, but it has require statements for optional dependencies in a try statement (see source here). This breaks the browserify build with a message like
Error: Cannot find module 'lame' from 'such/and/such/a/location'
It seems like someone else was having the same problem a few months ago, but is this really a problem with this particular library's implementation, or does this come up a lot with other libraries that have optional CommonJS-required dependencies?
I tried a browserify transform ('remove-try-require') that was supposed to strip require statements out of try blocks, but it didn't seem to work.
Is there a common practice for dealing with such things? Is the try-catch require statement bad form? What other ways might one handle optional dependencies?
Thanks!
(P.S. - A quick solution would be to get those optional dependencies, but I don't want them.)
You compile with the --ignore-missing
flag to ignore them.
browserify timbre.node.js --ignore-missing