Mac中 npm install 报错 `gyp` failed with exit code: 1

npm node-gyp rebuild - Error: gyp failed with exit code: 1

Mac中 npm install 报错 `gyp` failed with exit code: 1解决方法
Mac升级到High sierra 后,发现执行使用npm 或者yarn 的时候,不时会报gyp: No Xcode or CLT version detected! 的错误, 原因是缺了xcode 的CLI 工具, 只要执行下面的命令来安装就可以了。

sudo xcode-select --install

如果出现错误:xcode-select: error: command line tools are already installed, use “Software Update” to install
解决办法在这