问题描述:

安装npm包的时候一直提示以下错误

/Applications/Xcode.app/Contents/Developer/usr/bin/make -C out BUILDTYPE=Release V=1 rm -f /Users/bwkahle/git/io.js/out/Release/libgtest.a && ./gyp-mac-tool filter-libtool libtool -static -o /Users/bwkahle/git/io.js/out/Release/libgtest.a /Users/bwkahle/git/io.js/out/Release/obj.target/gtest/deps/gtest/src/gtest-death-test.o /Users/bwkahle/git/io.js/out/Release/obj.target/gtest/deps/gtest/src/gtest-filepath.o /Users/bwkahle/git/io.js/out/Release/obj.target/gtest/deps/gtest/src/gtest-port.o /Users/bwkahle/git/io.js/out/Release/obj.target/gtest/deps/gtest/src/gtest-printers.o /Users/bwkahle/git/io.js/out/Release/obj.target/gtest/deps/gtest/src/gtest-test-part.o /Users/bwkahle/git/io.js/out/Release/obj.target/gtest/deps/gtest/src/gtest-typed-test.o /Users/bwkahle/git/io.js/out/Release/obj.target/gtest/deps/gtest/src/gtest.o /Users/bwkahle/git/io.js/out/Release/obj.target/gtest/deps/gtest/src/gtest_main.o libtool: unrecognized option -static' libtool: Trylibtool --help' for more information. make[1]: [/Users/bwkahle/git/io.js/out/Release/libgtest.a] Error 1 make: [iojs] Error 2

问题原因:

mac下使用homebrew安装过libtool 覆盖了系统的libtool路径,可以使用 which libtool查看路径

比如,我的返回的是

/usr/local/bin/libtool

解决办法:

还原回系统的libtool

brew unlink libtool
rm -rf /usr/local/bin/libtool
which libtool