Error building libxmljs for node.js

2019-07-16 16:09发布

问题:

I'm having a problems building libxmljs on my mac os x 10.9.3.

Here's what I'm getting:

3 warnings generated.
  CC(target) Release/obj.target/libxml/vendor/libxml/xpointer.o
  LIBTOOL-STATIC Release/xml.a
libtool: unrecognized option `-static'
libtool: Try `libtool --help' for more information.
make: *** [Release/xml.a] Error 1
gyp ERR! build error
gyp ERR! stack Error: `make` failed with exit code: 2
gyp ERR! stack     at ChildProcess.onExit (/usr/local/lib/node_modules/npm/node_modules/node-gyp/lib/build.js:267:23)
gyp ERR! stack     at ChildProcess.EventEmitter.emit (events.js:98:17)
gyp ERR! stack     at Process.ChildProcess._handle.onexit (child_process.js:789:12)
gyp ERR! System Darwin 13.2.0
gyp ERR! command "node" "/usr/local/lib/node_modules/npm/node_modules/node-gyp/bin/node-gyp.js" "rebuild"
gyp ERR! cwd /usr/local/lib/node_modules/libxmljs
gyp ERR! node -v v0.10.13
gyp ERR! node-gyp -v v0.10.2
gyp ERR! not ok
unbuild libxmljs@0.10.0
npm ERR! weird error 1
npm ERR! not ok code 0

So... It's some wierd error 1. Can't really figure out what exactly.

The node installed with homebrew.

回答1:

Okay. Here's the deal. There's a described problem with building modules for homebrew installed node.js.

libtool: unrecognized option `-static'

http://flummox-engineering.blogspot.ru/2014/04/libtool-unrecognized-option-static.html

This happenes when you're using homebrew's libtool. You should use systemwide that's located in /usr/bin/libtool.

To fix this issue you can type which libtool. If it is in /usr/local/Cellar/libtool.... then it's homebrew's one. Just unlink it with this command:

brew unlink libtool

Do your npm install and link it back again

brew link libtool

In my case i had libtool installed with MAMP. So I edited my ~/.bash_profile file and removed that PATH="/Applications/MAMP/Library/bin:${PATH}" line i recently added my my own.