I have a library that I want to use in both client side and server side. However, because request is not compatible with browserify, when compiling using browserify
The accepted answer is correct. But if you got here by googling 'detect browserify' and want the more general answer, browserify automatically transforms the node-provided global process. You can use:
process.browser
which will be true in the browser, undefined in node.