how to detect when browserify is being run?

后端 未结 3 1662
离开以前
离开以前 2021-02-02 12:53

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

3条回答
  •  情歌与酒
    2021-02-02 13:02

    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.

提交回复
热议问题