mcollina / msgpack5

A msgpack v5 implementation for node.js, with extension points / msgpack.org[Node]
MIT License
492 stars 76 forks source link

process is not defined in the browser #72

Closed sharok closed 6 years ago

sharok commented 6 years ago

I am using angular 6 and signalr for webstockets. SignalR uses this library for binary data. Now I get the following error:

index.js:3 Uncaught ReferenceError: process is not defined
    at Object../node_modules/process-nextick-args/index.js (index.js:3)
    at __webpack_require__ (bootstrap:76)
    at Object../node_modules/readable-stream/lib/_stream_duplex.js (_stream_duplex.js:31)
    at __webpack_require__ (bootstrap:76)
    at Object../node_modules/readable-stream/duplex-browser.js (duplex-browser.js:1)
    at __webpack_require__ (bootstrap:76)
    at Object../node_modules/bl/bl.js (bl.js:1)
    at __webpack_require__ (bootstrap:76)
    at Object../node_modules/msgpack5/index.js (index.js:5)
    at __webpack_require__ (bootstrap:76)

if I put workaround like:

(window as any).process = {
  env: { DEBUG: undefined },
};

Then, I start getting error about Buffer

util.js:103 Uncaught ReferenceError: Buffer is not defined
    at Object../node_modules/core-util-is/lib/util.js (util.js:103)
    at __webpack_require__ (bootstrap:76)
    at Object../node_modules/readable-stream/lib/_stream_duplex.js (_stream_duplex.js:46)
    at __webpack_require__ (bootstrap:76)
    at Object../node_modules/readable-stream/duplex-browser.js (duplex-browser.js:1)
    at __webpack_require__ (bootstrap:76)
    at Object../node_modules/bl/bl.js (bl.js:1)
    at __webpack_require__ (bootstrap:76)
    at Object../node_modules/msgpack5/index.js (index.js:5)
    at __webpack_require__ (bootstrap:76)

For the notice, I used msgpack-lite and it worked fine.

mcollina commented 6 years ago

what are you using to bundle this?

sharok commented 6 years ago

I figure out the problem, my fault. I will close the issue. Thanks.