3,421   NodeJS

node-gyp rebuild 有时会卡住,等了好久会报错

Failed at the bcrypt@0.8.5 install script 'node-gyp rebuild'

对于npm包安装的内部流程不太了解,上网各种google
看了几篇文章有点头绪了,
http://www.bubuko.com/infodetail-827600.html
https://github.com/nodejs/node-gyp/issues/787

大概原因
1,node-gyp rebuild会去寻找nodejs的headers文件,没有的话会去官网下载
2,如果网络好的话,下载速度很快安装好,网络不好就不会一直卡住,甚至会报超时错误导致安装不成功

参照上面文章的解决方法,先去下载对应版本nodejs的headers,然后解压放到node-gyp相应目录即可

wget https://nodejs.org/download/release/v4.2.4/node-v4.2.4-headers.tar.gz
tar zxf node-v4.2.4-headers.tar.gz -C ~/.node-gyp
mv ~/.node-gyp/node-v4.2.4 ~/.node-gyp/4.2.4
printf "9" >  ~/.node-gyp/4.2.4/installVersion



Leave a Reply

Your email address will not be published. Required fields are marked *