简体   繁体   English

npm install 报错

[英]npm install gives errors

I can't succeed with npm install packages after $npm install, it shows this output:在 $npm install 之后我无法使用 npm install 包成功,它显示了以下输出:

> canvas@1.6.7 install /home/samuel/testes/Avanade Angular Academy by Gama/gama-avanade-tryout01/node_modules/canvas
> node-gyp rebuild

./util/has_lib.sh: 31: ./util/has_lib.sh: pkg-config: not 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 (/home/samuel/.npm-global/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:219:12)
gyp ERR! System Linux 4.9.0-4-amd64
gyp ERR! command "/usr/bin/node" "/home/samuel/.npm-global/lib/node_modules/npm/node_modules/node-gyp/bin/node-gyp.js" "rebuild"
gyp ERR! cwd /home/samuel/testes/Avanade Angular Academy by Gama/gama-avanade-tryout01/node_modules/canvas
gyp ERR! node -v v6.12.0
gyp ERR! node-gyp -v v3.6.2
gyp ERR! not ok 
npm ERR! code ELIFECYCLE
npm ERR! errno 1
npm ERR! canvas@1.6.7 install: `node-gyp rebuild`
npm ERR! Exit status 1
npm ERR! 
npm ERR! Failed at the canvas@1.6.7 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/samuel/.npm/_logs/2017-12-12T02_40_55_700Z-debug.log

What should I do?我该怎么办? Thanks for all of you help!谢谢大家的帮助!

The solution is to install some external dependencies.解决方案是安装一些外部依赖项。 The commands below were enough.下面的命令就足够了。

$ sudo apt-get update 
$ sudo apt-get install libcairo2-dev libjpeg-dev libpango1.0-dev libgif-dev build-essential g++

After this, $npm install works!在此之后, $npm install 起作用了!

delete node modules and package-lock.json删除节点模块和 package-lock.json

1.yarn install or npm install 2.npm start 1.yarn install 或 npm install 2.npm start

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM