安装webpack ,报错提示
gyp ERR! configure error
gyp ERR! stack Error: `gyp` failed with exit code: 1
gyp ERR! stack at ChildProcess.onCpExit (/usr/local/lib/node_modules/cnpm/node_modules/node-gyp/lib/configure.js:345:16)
gyp ERR! stack at ChildProcess.emit (events.js:400:28)
gyp ERR! stack at Process.ChildProcess._handle.onexit (internal/child_process.js:277:12)
gyp ERR! System Darwin 20.5.0
gyp ERR! command "/usr/local/bin/node" "/usr/local/lib/node_modules/cnpm/node_modules/npminstall/node-gyp-bin/node-gyp.js" "rebuild"
gyp ERR! cwd /usr/local/lib/node_modules/webpack/node_modules/_fsevents@1.2.13@fsevents
gyp ERR! node -v v14.17.4
gyp ERR! node-gyp -v v4.0.0
gyp ERR! not ok
解决方案
阅读报错信息,尝试各种方案,终于解决!
首先在终端输入下面命令下载
xcode-select --install
1.如果报错如下
xcode-select: error: command line tools are already installed, use "Software Update" to install updates
2.表示已经存在,重置即可
xcode-select --reset
如果下载 xcode-select失败,那就需要到官方给开发者提供的下载处直接去下载命令行工具(Command Line Tools)
1.地址:https://developer.apple.com/download/all/
2.在搜索框,搜索:Command Line Tools
3. 选择合适的版本下载即可
4.安装简单,傻瓜式安装即可,安装完成后,再执行上述两个命令即可
xcode-select --install
1.如果报错如下
xcode-select: error: command line tools are already installed, use "Software Update" to install updates
2.表示已经存在,重置即可
xcode-select --reset