当前位置: 首页 > 知识库问答 >
问题:

运行npm安装时出现节点gyp错误

卜高超
2023-03-14

我是新来的节点,有点超出我的深度。在Mac OS X和Centos 6上都遇到此错误。发生在我尝试过的所有npm install xxx命令中。任何关于如何避免这一错误的建议都将不胜感激。

类似于npm,安装时会出现节点gyp错误,但我的用户名中没有空格,这就解决了他的问题。

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

共有2个答案

谢阳曜
2023-03-14

我也犯了同样的错误,原因是我没有安装clang编译器。我的解决方案是安装build essential软件包

sudo apt-get install build-essential

我使用的是Ubuntu 20.1版本

农飞翔
2023-03-14

这是一个已知的画布问题,可能是由于缺少本机lib造成的
试试这个,看看是否有帮助:

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

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

 类似资料:
  • 我在安装NPM时遇到以下错误: npm WARN Worker-Loader@0.8.1需要WebPack@>=0.9<2^2.1.0-Beta^2.2.0的对等项,但未安装任何对等项。 npm警告可选跳过可选依赖项:fsevents@1.1.2(node_modules\fsevents): npm WARN notsup跳过可选依赖项:fsevents@1.1.2:wanted平台不受支持{“

  • 我正在尝试使用NPM5.6.0在Windows 10上安装模块。当我进入npm安装时,我得到: 似乎节点sass安装错误。环境如下: Python版本:2.7.14 npm版本:5.6.0 节点版本:8.10.0 ruby版本: 2.3.3p222 (2016-11-21修订56859)[i386-mingw32] 系统:win10(x64) node-gyp: 3.6.2 而且我已经安装了Mic

  • 我是一个初学者,我正在努力学习角,所以我试图安装一个新的项目与角种子。但是当我安装npm时,我得到一个错误,我不知道是从哪里来的。我已经安装了节点。版本是5.5.0。这是我在控制台得到的错误。

  • 我正在尝试在我的服务器上安装yeoman,但由于某些原因,我一直收到一个权限被拒绝的错误。 我曾尝试重新安装ubuntu(14.04),但没有任何效果。

  • TypeError:未定义的类扩展值不是构造函数或对象处为null。(C:\Program Files\nodejs\NodeU modules\npm\node\U modules\socks proxy agent\dist\agent.js:114:44)位于模块_在对象处编译(节点:内部/模块/cjs/加载程序:1101:14)。模块_扩展。。模块处的js(节点:内部/模块/cjs/加载程