0

The Pace library (Pace-Progress is the name of it on NPM because Pace was already taken) is throwing this error when imported. I am using Angular2 and Webpack. The line of code throwing the error is

exports.isBuffer = Buffer.isBuffer;

I have a buffer library available from NPM was well, but why would Pace be expecting me to load another library in advance for it to work? What could I be doing wrong?

Josh
  • 1,648
  • 8
  • 27
  • 58
  • It isn't clear why client-side library may use `Buffer`, because it is a part of Node api. I would suggest to investigate why it is used in the bundle in the first place. But the most simple way to use it in bundle is to use [Webpack polyfills for that](https://webpack.github.io/docs/configuration.html#node). – Estus Flask Nov 10 '16 at 01:12
  • Thanks! I set the buffer option to true in webpack and the error went away. – Josh Nov 10 '16 at 04:02
  • If you submit an answer with this I will mark it correct, as the polyfill buffer option was ultimately what got it working – Josh Nov 15 '16 at 21:19
  • Sure, you're welcome. – Estus Flask Nov 15 '16 at 21:43

1 Answers1

1

Buffer is a part of Node API and usually shouldn't be found in client side code.

Most simple way to use it in bundle is to use Webpack polyfills.

Estus Flask
  • 206,104
  • 70
  • 425
  • 565