nypublicradio / audiogram

Turn audio into a shareable video.

Geek Repo:Geek Repo

Github PK Tool:Github PK Tool

Install failed at the canvas@1.6.0 install script

chill-fpraz opened this issue · comments

Posting this for anyone having the same issue. Since it's a local mac install, the dependency issues may not apply to other setups.

My Setup

  • Mac OS X 10.13.5
  • Xcode 9.4
  • Git 2.15.1
  • Node 10.3.0

Steps

Followed Mac OS X installation instructions in INSTALL.md (using Homebrew):

brew install pkg-config cairo pango libpng jpeg giflib ffmpeg
git clone https://github.com/nypublicradio/audiogram.git
cd audiogram
npm install

Received 15 warnings and 7 errors. Errors were for 'TryCatch' and 'HasOwnProperty' in /src/Canvas.cc:

error: no matching constructor for initialization of 'v8::TryCatch'
error: no matching member function for call to 'HasOwnProperty'

Upgraded to Canvas 2.0.0-alpha.12
npm install canvas@next

That fixed the install errors, but when running npm start and trying to generate mp4, rec'd this error:

TypeError: Canvas is not a constructor
    at drawFrames (/Applications/audiogram/audiogram/draw-frames.js:12:19)
    at /Applications/audiogram/audiogram/index.js:112:5
    at initializeCanvas (/Applications/audiogram/audiogram/initialize-canvas.js:12:12)
    at Audiogram.drawFrames (/Applications/audiogram/audiogram/index.js:104:3)
    at start (/Applications/audiogram/node_modules/d3-queue/build/d3-queue.js:74:11)
    at poke (/Applications/audiogram/node_modules/d3-queue/build/d3-queue.js:58:11)
    at /Applications/audiogram/node_modules/d3-queue/build/d3-queue.js:90:23
    at /Applications/audiogram/audiogram/index.js:61:14
    at Stream.<anonymous> (/Applications/audiogram/audiogram/waveform.js:27:12)
    at Stream.emit (events.js:182:13)

A Fix

Found this issue which identifies new function: Canvas.createCanvas()

In /audiogram/audiogram/draw-frames.js, changed line 12 from

canvases.push(new Canvas(options.width, options.height));
to
canvases.push(new Canvas.createCanvas(options.width, options.height));

Not sure if the code change above should be added as a pull request since it involves Canvas 2.x - maybe a version check could switch between the two?

I created a github account just to say: thank you!

Hi - could someone from WNYC update the instructions to include this:

npm install canvas@next

The default instructions failed on FreeBSD, so I went chasing around for that, then the OS-X instructions failed on OS-X so I installed Ubuntu in a VM and again, similar errors during the Canvas build.

After a few hours, I landed on this issue and I now have this running on all 3 OSes. If this info were in the README, it would have been super helpful!