canvas-plus icon indicating copy to clipboard operation
canvas-plus copied to clipboard

Getting process.hrtime is not a function error when running on Chrome

Open mikemklee opened this issue 5 years ago • 1 comments

I am running a React application, so I included the package using yarn add pixl-canvas-plus.

However, when I try to make an instance of the module using var canvasPlus = new CanvasPlus(), I get an error with the following message:

TypeError: process.hrtime is not a function

I believe this is because I am not running on Node.js, but instead running on Chrome.

There seems to be some dependencies that will only work with Node.js.

Any ideas on how to go around this issue? I tried out the demo, and really like it, so it would be awesome if I could actually get it to work in my application.

mikemklee avatar Nov 25 '19 14:11 mikemklee

Hello, and sorry for the confusion over this. The library is split into two separate modules: one for Node.js, and one for use in the browser / client. The browser / client library must be loaded differently:

https://github.com/jhuckaby/canvas-plus#browser

So download the canvas-plus.js file from the provided URL, or pull it out of your module distribution that you got from npm, host it on your web server with your app, and load it in your browser using a standard SCRIPT tag:

<script src="canvas-plus.js"></script>

Please note that the client-side library is quite large (750K raw, 180K compressed), due to all the dependencies compiled into that one combo dist file.

Hope this helps.

jhuckaby avatar Nov 26 '19 03:11 jhuckaby