13

I'm new to node and a bit out of my depth here. Experiencing this error on both Mac OS X and Centos 6. Happens in all the npm install xxx commands I've tried. Any suggestions on how to get around this error much appreciated.

Similar to npm install gives node-gyp error but I do not have spaces in my username which is what solved his issue.

npm install canvas

> canvas@1.6.6 install /home/test1/ng2-webpack-demo/node_modules/canvas
> node-gyp rebuild

Package cairo was not found in the pkg-config search path.
Perhaps you should add the directory containing `cairo.pc'
to the PKG_CONFIG_PATH environment variable
No package 'cairo' found
gyp: Call to './util/has_lib.sh freetype' returned exit status 0 while in 
binding.gyp. while trying to load binding.gyp
gyp ERR! configure error
gyp ERR! stack Error: `gyp` failed with exit code: 1
gyp ERR! stack     at ChildProcess.onCpExit 
(/usr/lib/node_modules/npm/node_modules/node-gyp/lib/configure.js:336:16)
gyp ERR! stack     at emitTwo (events.js:106:13)
gyp ERR! stack     at ChildProcess.emit (events.js:191:7)
gyp ERR! stack     at Process.ChildProcess._handle.onexit 
(internal/child_process.js:215:12)
gyp ERR! System Linux 2.6.32-642.4.2.el6.x86_64
gyp ERR! command "/usr/bin/node" "/usr/lib/node_modules/npm/node_modules/node-
gyp/bin/node-gyp.js" "rebuild"
gyp ERR! cwd /home/test1/ng2-webpack-demo/node_modules/canvas
gyp ERR! node -v v6.11.1
gyp ERR! node-gyp -v v3.6.2
gyp ERR! not ok
npm WARN @angular/animations@4.3.6 requires a peer of @angular/core@4.3.6 but 
none was installed.
npm WARN @angular/material@2.0.0-beta.8 requires a peer of @angular/cdk@2.0.0-
beta.8 but none was installed.
npm WARN @angular/material@2.0.0-beta.8 requires a peer of 
@angular/core@^4.0.0 but none was installed.
npm WARN @angular/material@2.0.0-beta.8 requires a peer of 
@angular/common@^4.0.0 but none was installed.
npm WARN @ngtools/webpack@1.2.10 requires a peer of @angular/tsc-
wrapped@^0.5.0 but none was installed.
npm WARN optional SKIPPING OPTIONAL DEPENDENCY: fsevents@1.1.2 
(node_modules/fsevents):
npm WARN notsup SKIPPING OPTIONAL DEPENDENCY: Unsupported platform for 
fsevents@1.1.2: wanted {"os":"darwin","arch":"any"} (current: 
{"os":"linux","arch":"x64"})

npm ERR! code ELIFECYCLE
npm ERR! errno 1
npm ERR! canvas@1.6.6 install: `node-gyp rebuild`
npm ERR! Exit status 1
npm ERR!
npm ERR! Failed at the canvas@1.6.6 install script.
npm ERR! This is probably not a problem with npm. There is likely additional 
logging output above.

npm ERR! A complete log of this run can be found in:
npm ERR!     /home/test1/.npm/_logs/2017-08-29T15_54_58_848Z-debug.log
mba12
  • 2,702
  • 6
  • 37
  • 56
  • For those who come along the way I solved this was to switch to a centos 7 box and then run rpm -ivh https://kojipkgs.fedoraproject.org//packages/http-parser/2.7.1/3.el7/x86_64/http-parser-2.7.1-3.el7.x86_64.rpm && yum -y install nodejs according to: https://bugs.centos.org/view.php?id=13669&nbn=1 – mba12 Sep 06 '17 at 15:53
  • check this link: https://stackoverflow.com/questions/44316064/gyp-err-build-error-stack-error-make-failed-with-exit-code-2 – mohammad javad ahmadi Sep 15 '19 at 08:08
  • None of the comments in this post seem to explain why it's intermittent, at least for me. Re-ran exactly the same build on the same machine and it worked just fine. – Dylan Nicholson Apr 11 '22 at 02:33

2 Answers2

10

This is a known canvas issue, probably caused by missing native libs.
Try this see if it helps:

sudo npm uninstall -g node-gyp
sudo npm install -g node-gyp
brew install pkg-config cairo libpng jpeg giflib
npm i canvas

Source: https://github.com/Automattic/node-canvas/issues/913#issuecomment-368042394

Shan
  • 564
  • 5
  • 11
3

I've same error the reason was that I don't have clang compiler installed. My solution to this was to install build-essential package

sudo apt-get install build-essential

I'm using Ubuntu 20.1 release

atrichkov
  • 450
  • 3
  • 6