Search code examples
browserify

show error line and file when compile coffeeify


How to make browserify show error line and file on compile:

browserify  -t coffeeify mainPage_browserify.coffee > main.js -d    

The current output don't give this information. So it is hard to debug:

                                                                                                                                ⏎
Error: Cannot find module 'throw' from '/allProjectsPath/project/public/javascripts/map'
  at /usr/local/lib/node_modules/browserify/node_modules/resolve/lib/async.js:50:17
  at process (/usr/local/lib/node_modules/browserify/node_modules/resolve/lib/async.js:119:43)
  at /usr/local/lib/node_modules/browserify/node_modules/resolve/lib/async.js:128:21
  at load (/usr/local/lib/node_modules/browserify/node_modules/resolve/lib/async.js:60:43)
  at /usr/local/lib/node_modules/browserify/node_modules/resolve/lib/async.js:66:22
  at /usr/local/lib/node_modules/browserify/node_modules/resolve/lib/async.js:21:47
  at Object.oncomplete (fs.js:107:15)



❯ browserify --version                                                                                                                                                                                    ⏎
5.12.1

Solution

  • I was interested in this by myself, so I had a quick peek into source code and run debugger. It looks like that errors from transforms are basically swallowed when using command line browserify.

    Errors from coffeeify are passed using event emitter on the stream...

    https://github.com/substack/coffeeify/blob/master/index.js#L35

    These are handled by Browserify only if the bundle call was made with callback present...

    https://github.com/substack/node-browserify/blob/master/index.js#L619

    Unfortunately callback is not passed when running the command line...

    https://github.com/substack/node-browserify/blob/master/bin/cmd.js#L55