Last active
May 17, 2018 11:33
-
-
Save hced/8e816a83aacf4d7e2c2d to your computer and use it in GitHub Desktop.
Attempt to fix node-gyp error: No package 'cairo' found
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
# Fix node-gyp error: "No package 'cairo' found" | |
# | |
# Installs Pixman, Cairo and (if absent) pkg-config | |
# N.B. You may want to first cd into a preferred source directory (e.g. ~/src). | |
# | |
# Desc: | |
# This script attempts to fix a node-gyp error, "No package 'cairo' found", | |
# (that in my case appeared) when trying to npm install --save metalsmith-stylus. | |
# Basically, installing Cairo + Pixman (http://www.cairographics.org/) did the | |
# trick for me. (Might come in handy in similar situations with the same error.) | |
# | |
# You may want to check for newer/specific versions of specified libs first. | |
# / @hced 2014-10-18 | |
lets_do_this() { | |
install_pixman() { | |
echo "\nInstalling Pixman ...\n" | |
curl http://www.cairographics.org/releases/pixman-0.32.6.tar.gz -o pixman.tar.gz | |
tar -zxf pixman.tar.gz | |
cd pixman-0.32.6 | |
./configure --prefix=/usr/local --disable-dependency-tracking | |
make install | |
cd .. | |
} | |
install_cairo() { | |
echo "\nInstalling Cairo ...\n" | |
curl http://cairographics.org/releases/cairo-1.14.0.tar.xz -o cairo.tar.xz | |
tar -zxf cairo.tar.xz | |
cd cairo-1.14.0 | |
./configure --prefix=/usr/local --disable-dependency-tracking | |
make install | |
cd .. | |
} | |
if ! which pkg-config | |
then | |
echo "\npkg-config was not found in PATH. Installing it now ...\n" | |
# Check whether pkg-config exist and install if not | |
curl http://pkgconfig.freedesktop.org/releases/pkg-config-0.28.tar.gz -o pkgconfig.tgz | |
tar -zxf pkgconfig.tgz | |
cd pkg-config-0.28 | |
./configure | |
make install | |
cd .. | |
install_pixman | |
install_cairo | |
else | |
echo "\npkg-config installation skipped since it was found in PATH.\n" | |
install_pixman | |
install_cairo | |
fi | |
} | |
# Prompt for user confirmation | |
echo "This script does the following ...\n | |
1) Install pkg-config if it doesn't exist (pkg-config-0.28)\n | |
2) Install Pixman (to accompany Cairo) (pixman-0.32.6)\n | |
3) Install Cairo (cairo-1.14.0)\n" | |
# Prompt for user confirmation to continue | |
while true; do | |
read -p "Do you wish to continue? (Yes/No) " yn | |
case $yn in | |
[Yy]* ) lets_do_this; break;; | |
[Nn]* ) echo "Ok then. Goodbye."; exit;; | |
* ) echo "Please answer (Y)es or (N)o.";; | |
esac | |
done |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment