解决 binding.gyp not found (xxx/xxx/xxx) while trying to load binding.gyp 问题

在使用ccap图形验证码模块时遇到这个问题

Error: gyp failed with exit code: 1

于是我手动删了rm -rf ~/.node-gyp/ 目录下的文件重新执行了npm install node-gyp -g,但并没有解决问题,反而来了一个新问题
binding.gyp not found (xxx/xxx/xxx) while trying to load binding.gyp
这个就尴尬了,网上一番查找折腾,最终用如下方法解决问题

更新一下npm

sudo npm cache clean -f
sudo npm install npm -g

重新安装node-gyp 来替换node自带node-gyp

sudo npm uninstall node-gyp -g
sudo npm uninstall node-gyp
sudo npm install node-gyp -g 

然后就好了。

猜你喜欢

转载自blog.csdn.net/StillCity/article/details/77483085