Failed at the bufferutil@4.0.2 install script 'node-gyp-build'.
mac系统下执行 sudo npm install --registry=https://registry.npm.taobao.org 时提示错误信息 Failed at the bufferutil@4.0.2 install script 'node-gyp-build'.
mac系统下执行 sudo npm install --registry=https://registry.npm.taobao.org 时提示错误信息 Failed at the bufferutil@4.0.2 install script 'node-gyp-build'.
其中有一条
../src/bufferutil.c:3:10: fatal error: 'node_api.h' file not found #include <node_api.h>
完整输出如下:
sudo npm install --registry=https://registry.npm.taobao.org > bufferutil@4.0.2 install /Users/aven/Documents/xslgy/vue-element-admin/node_modules/bufferutil > node-gyp-build xcode-select: error: tool 'xcodebuild' requires Xcode, but active developer directory '/Library/Developer/CommandLineTools' is a command line tools instance xcode-select: error: tool 'xcodebuild' requires Xcode, but active developer directory '/Library/Developer/CommandLineTools' is a command line tools instance CC(target) Release/obj.target/bufferutil/src/bufferutil.o ../src/bufferutil.c:3:10: fatal error: 'node_api.h' file not found #include <node_api.h> ^~~~~~~~~~~~ 1 error generated. make: *** [Release/obj.target/bufferutil/src/bufferutil.o] Error 1 gyp ERR! build error gyp ERR! stack Error: `make` failed with exit code: 2 gyp ERR! stack at ChildProcess.onExit (/Users/aven/.nvm/versions/node/v4.9.1/lib/node_modules/npm/node_modules/node-gyp/lib/build.js:276:23) gyp ERR! stack at emitTwo (events.js:87:13) gyp ERR! stack at ChildProcess.emit (events.js:172:7) gyp ERR! stack at Process.ChildProcess._handle.onexit (internal/child_process.js:211:12) gyp ERR! System Darwin 16.7.0 gyp ERR! command "/Users/aven/.nvm/versions/node/v4.9.1/bin/node" "/Users/aven/.nvm/versions/node/v4.9.1/lib/node_modules/npm/node_modules/node-gyp/bin/node-gyp.js" "rebuild" gyp ERR! cwd /Users/aven/Documents/xslgy/vue-element-admin/node_modules/bufferutil gyp ERR! node -v v4.9.1 gyp ERR! node-gyp -v v3.4.0 gyp ERR! not ok npm ERR! Darwin 16.7.0 npm ERR! argv "/Users/aven/.nvm/versions/node/v4.9.1/bin/node" "/Users/aven/.nvm/versions/node/v4.9.1/bin/npm" "install" "--registry=https://registry.npm.taobao.org" npm ERR! node v4.9.1 npm ERR! npm v2.15.11 npm ERR! code ELIFECYCLE npm ERR! bufferutil@4.0.2 install: `node-gyp-build` npm ERR! Exit status 1 npm ERR! npm ERR! Failed at the bufferutil@4.0.2 install script 'node-gyp-build'. npm ERR! This is most likely a problem with the bufferutil package, npm ERR! not with npm itself. npm ERR! Tell the author that this fails on your system: npm ERR! node-gyp-build npm ERR! You can get information on how to open an issue for this project with: npm ERR! npm bugs bufferutil npm ERR! Or if that isn't available, you can get their info via: npm ERR! npm ERR! npm owner ls bufferutil npm ERR! There is likely additional logging output above. npm ERR! Please include the following file with any support request: npm ERR! /Users/aven/Documents/xslgy/vue-element-admin/npm-debug.log
从输出可以看出 node -v v4.9.1,这是因为 node 版本太低了,切换到 nvm use 8.17.0 或更高版本试试。
本文由 微wx笑 创作,采用 署名-非商业性使用-相同方式共享 4.0 许可协议,转载请附上原文出处链接及本声明。
原文链接:https://www.ivu4e.cn/blog/front/2020-12-14/572.html