[Mac] Error During Node.js Installation: Build failed: -> task failed (err #2): {task: uv uv.h -> uv.a}
Here’s how I solved the problem where Node.js couldn’t be installed after installing Command Line Tools in Xcode and also installing osx-gcc-installer.
% nvm install v0.6.19
Additional options while compiling:
######################################################################## 100.0%
Checking for program g++ or c++ : /usr/bin/g++
Checking for program cpp : /usr/bin/cpp
Checking for program ar : /usr/bin/ar
Checking for program ranlib : /usr/bin/ranlib
Checking for g++ : ok
Checking for program gcc or cc : /usr/bin/gcc
Checking for gcc : ok
Checking for library dl : yes
Checking for openssl : yes
Checking for library util : yes
Checking for library rt : not found
Checking for fdatasync(2) with c++ : no
'configure' finished successfully (0.250s)
Waf: Entering directory `/Users/your_username/.nvm/src/node-v0.6.19/out'
DEST_OS: darwin
DEST_CPU: x64
Parallel Jobs: 1
Product type: program
[ 1/35] copy: src/node_config.h.in -> out/Release/src/node_config.h
[ 2/35] cc: deps/http_parser/http_parser.c -> out/Release/deps/http_parser/http_parser_3.o
/usr/bin/gcc -rdynamic -pthread -m64 -arch x86_64 -g -O3 -DHAVE_OPENSSL=1 -D_LARGEFILE_SOURCE -D_FILE_OFFSET_BITS=64 -D_DARWIN_USE_64_BIT_INODE=1 -DHAVE_FDATASYNC=0 -DARCH="x64" -DPLATFORM="darwin" -D__POSIX__=1 -Wno-unused-parameter -D_FORTIFY_SOURCE=2 -IRelease/deps/http_parser -I../deps/http_parser ../deps/http_parser/http_parser.c -c -o Release/deps/http_parser/http_parser_3.o
[ 3/35] src/node_natives.h: src/node.js lib/dgram.js lib/console.js lib/buffer.js lib/querystring.js lib/punycode.js lib/http.js lib/net.js lib/stream.js lib/events.js lib/util.js lib/module.js lib/_debugger.js lib/assert.js lib/fs.js lib/child_process.js lib/os.js lib/readline.js lib/vm.js lib/url.js lib/tls.js lib/crypto.js lib/sys.js lib/https.js lib/freelist.js lib/dns.js lib/_linklist.js lib/buffer_ieee754.js lib/tty.js lib/cluster.js lib/repl.js lib/path.js lib/string_decoder.js lib/timers.js lib/zlib.js lib/constants.js -> out/Release/src/node_natives.h
[ 4/35] uv: deps/uv/include/uv.h -> out/Release/deps/uv/uv.a
rm -f src/ares/*.o
rm -f src/unix/ev/*.o
rm -f src/unix/eio/*.o
rm -f src/unix/*.o
rm -rf test/run-tests.dSYM run-benchmarks.dSYM
rm -f -f src/*.o *.a test/run-tests test/run-benchmarks
...
make[1]: *** [src/unix/darwin.o] Error 1
Waf: Leaving directory `/Users/your_username/.nvm/src/node-v0.6.19/out'
Build failed: -> task failed (err #2):
{task: uv uv.h -> uv.a}
make: *** [program] Error 1
nvm: install v0.6.19 failed!
It seems that if you’re going to use Xcode’s Command Line Tools, you shouldn’t have installed osx-gcc-installer in the first place.
By uninstalling with the following command and reinstalling Command Line Tools, I was able to install Node.js normally.
% sudo /Library/Developer/Shared/uninstall-devtools --mode=all
If you need GNU GCC 4.2, it would be better to just install it with Homebrew.
brew install apple-gcc42
That’s all from the Gemba.