hobberwickey
hobberwickey

Reputation: 6444

successfully compiled custom node.js module how do I use it

I was having a lot of problems using npm to install the canvas module for node.js, so I downloaded the source code, and used visual studio 2005 to debug and correct the errors I was running into. I got it to successfully compile, but now I don't know know where to go from there in order to be able to use it in my project. Seems like it should be easy, but I don't even know where to begin.

Upvotes: 0

Views: 130

Answers (1)

josh3736
josh3736

Reputation: 145002

Rename the compiled .dll file to .node and drop it in your node project. Then just require it.

For example, in a folder:

app.js
canvas.node
...

In app.js:

var canvas = require('./canvas');

Note that in the case of the canvas module, you should have no problems using npm to install it if you have a proper node native build environment (node-gyp) set up, which includes Python 2.7 and MS Visual C++ 2010 (and for x64 builds, the Win 7 x64 SDK). VS 2005 won't work.

You'll obviously also need cario installed since canvas depends on it.

Upvotes: 1

Related Questions