Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

Nodejs Cannot find module '../build/Release/canvas'

Tags:

I installed cairo, and node-canvas. I tried everything, but still can't find module.

sudo apt-get install libcairo2-dev sudo npm install canvas sudo npm install canvas -g 

If I run require('canvas'), I get this error:

Error: Cannot find module '../build/Release/canvas'     at Function._resolveFilename (module.js:332:11)     at Function._load (module.js:279:25)     at Module.require (module.js:354:17)     at require (module.js:370:17)     at Object.<anonymous> (/home/tomas/node_modules/canvas/lib/bindings.js:2:18)     at Module._compile (module.js:441:26)     at Object..js (module.js:459:10)     at Module.load (module.js:348:32)     at Function._load (module.js:308:12)     at Module.require (module.js:354:17) 

I use Ubuntu linux

Thanks in advance.

like image 779
friction Avatar asked Feb 08 '13 11:02

friction


2 Answers

In my case i have to spend lot of time to resolve this issue.

I just use "npm uninstall canvas" and then install using "npm i canvas"

Try this is if above option not works for you.

like image 51
akshay_sushir Avatar answered Sep 18 '22 02:09

akshay_sushir


I had the same problem. The issue was that the install script for node-canvas never got executed, which is why the build folder was missing.

In my case, removing the yarn.lock file was the solution, as it skipped the node-canvas package installation for some reason. Once I let npm take care of the packages, it successfully installed node-canvas, ran the install script and the build folder showed up again.

like image 31
Marcel Kalveram Avatar answered Sep 19 '22 02:09

Marcel Kalveram