Ubuntu 14.04:安装 `npmjs` 的 `vega` 包

Ubuntu 14.04:安装 `npmjs` 的 `vega` 包

我需要安装veganpmjs(参见这里)。但 $ sudo npm -g install vega会引发以下错误。任何帮助都将不胜感激。提前感谢您的帮助。

$ sudo apt-get install nodejs
$ sudo npm -g install npm

$ node --version
v0.10.33

$ nodejs --version
v0.10.33


$ sudo npm -g install vega

> [email protected] install /usr/lib/node_modules/vega/node_modules/canvas
> node-gyp rebuild

gyp WARN EACCES user "root" does not have permission to access the dev dir "/home/yaseen/.node-gyp/0.10.33"
gyp WARN EACCES attempting to reinstall using temporary dev dir "/usr/lib/node_modules/vega/node_modules/canvas/.node-gyp"
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_cairo_freetype.sh' returned exit status 0. 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:343:16)
gyp ERR! stack     at ChildProcess.emit (events.js:98:17)
gyp ERR! stack     at Process.ChildProcess._handle.onexit (child_process.js:810:12)
gyp ERR! System Linux 3.13.0-40-generic
gyp ERR! command "node" "/usr/lib/node_modules/npm/node_modules/node-gyp/bin/node-gyp.js" "rebuild"
gyp ERR! cwd /usr/lib/node_modules/vega/node_modules/canvas
gyp ERR! node -v v0.10.33
gyp ERR! node-gyp -v v1.0.2
gyp ERR! not ok 

> [email protected] install /usr/lib/node_modules/vega/node_modules/d3/node_modules/jsdom/node_modules/contextify
> node-gyp rebuild

gyp WARN EACCES user "root" does not have permission to access the dev dir "/home/yaseen/.node-gyp/0.10.33"
gyp WARN EACCES attempting to reinstall using temporary dev dir "/usr/lib/node_modules/vega/node_modules/d3/node_modules/jsdom/node_modules/contextify/.node-gyp"
make: Entering directory `/usr/lib/node_modules/vega/node_modules/d3/node_modules/jsdom/node_modules/contextify/build'
  CXX(target) Release/obj.target/contextify/src/contextify.o
  SOLINK_MODULE(target) Release/obj.target/contextify.node
  SOLINK_MODULE(target) Release/obj.target/contextify.node: Finished
  COPY Release/contextify.node
make: Leaving directory `/usr/lib/node_modules/vega/node_modules/d3/node_modules/jsdom/node_modules/contextify/build'
npm ERR! Linux 3.13.0-40-generic
npm ERR! argv "node" "/usr/bin/npm" "-g" "install" "vega"
npm ERR! node v0.10.33
npm ERR! npm  v2.1.10
npm ERR! code ELIFECYCLE

npm ERR! [email protected] install: `node-gyp rebuild`
npm ERR! Exit status 1
npm ERR! 
npm ERR! Failed at the [email protected] install script 'node-gyp rebuild'.
npm ERR! This is most likely a problem with the canvas package,
npm ERR! not with npm itself.
npm ERR! Tell the author that this fails on your system:
npm ERR!     node-gyp rebuild
npm ERR! You can get their info via:
npm ERR!     npm owner ls canvas
npm ERR! There is likely additional logging output above.

npm ERR! Please include the following file with any support request:
npm ERR!     /home/yaseen/npm-debug.log

答案1

以下命令修复了该问题。

sudo apt-get install libcairo2-dev
sudo apt-get install libjpeg-dev
sudo apt-get install libgif-dev

相关内容