ForbesLindesay / browserify-middleware

express middleware for browserify, done right
http://browserify.org
MIT License
381 stars 66 forks source link

A way to display errors #90

Closed singuerinc closed 6 years ago

singuerinc commented 9 years ago

Hi, I'm having some problems to see what kind of errors has my code. Right now when I make a mistake I don't have a proper way to figure out what is happening.

If I run browserify from the command line I see:

Error: Cannot find module 'FadeInOutRegion' from '/src/app/js/views'

but with browserify-middleware no error is displayed, it remains forever in that request.

GET /assets/js/bundle.js - - ms - -

This is the way I'm doing now:

app.get('/assets/js/bundle.js', browserify('./src/app/js/app.js', {
    debug: true
}));

There is a property or callback or something that I can write to the console? Thanks

ForbesLindesay commented 9 years ago

browserify-middleware passes the error to express's next function. If you have a default express setup with no custom error handling middleware, you'll get an error printed just like you would expect. If you have your own custom error handling middleware it will use that.

frastlin commented 7 years ago

Hello, does this work for errors in my browserified code? When I am missing a brace somewhere I get the singularly unhelpful code on my browser console: Error SyntaxError: expected expression, got '<'[Learn More] main.js:1

This really doesn't tell me anything considering that line one has a require to a module that has a lot of code in it as well as having several requires itself. I placed an error handler after my code and am sending the error to console.log, but nothing is happening. What else should I do?

My error handler looks like: .use((err, req, res, next) =>{ console.log(err) next(err) })

It is at the very end of my app.use chain.