我的所有项目似乎都不是这个问题,尤其是当我运行npm i(节点v6.9.4(npm v5.6.0)

/Applications/Xcode.app/Contents/Developer/Toolchains/XcodeDefault.xctoolchain/usr/include/c++/v1/__threading_support:25:11: fatal error:
          'pthread.h' file not found
    # include <pthread.h>


错误日志:

12788 verbose stack Error: farmhash@1.2.1 install: `node-gyp rebuild`
12788 verbose stack Exit status 1
12788 verbose stack     at EventEmitter.<anonymous> (/Users/tom.firth/.nvm/versions/node/v6.9.4/lib/node_modules/npm/node_modules/npm-lifecycle/index.js:285:16)
12788 verbose stack     at emitTwo (events.js:106:13)
12788 verbose stack     at EventEmitter.emit (events.js:191:7)
12788 verbose stack     at ChildProcess.<anonymous> (/Users/tom.firth/.nvm/versions/node/v6.9.4/lib/node_modules/npm/node_modules/npm-lifecycle/lib/spawn.js:55:14)
12788 verbose stack     at emitTwo (events.js:106:13)
12788 verbose stack     at ChildProcess.emit (events.js:191:7)
12788 verbose stack     at maybeClose (internal/child_process.js:877:16)
12788 verbose stack     at Process.ChildProcess._handle.onexit (internal/child_process.js:226:5)
12789 verbose pkgid farmhash@1.2.1
12790 verbose cwd /Users/tom.firth/Sites/the-works
12791 verbose Darwin 16.7.0
12792 verbose argv "/Users/tom.firth/.nvm/versions/node/v6.9.4/bin/node" "/Users/tom.firth/.nvm/versions/node/v6.9.4/bin/npm" "i"
12793 verbose node v6.9.4
12794 verbose npm  v5.6.0
12795 error code ELIFECYCLE
12796 error errno 1
12797 error farmhash@1.2.1 install: `node-gyp rebuild`
12797 error Exit status 1
12798 error Failed at the farmhash@1.2.1 install script.
12798 error This is probably not a problem with npm. There is likely additional logging output above.
12799 verbose exit [ 1, true ]


这两个都指向node-gyp rebuild-我以前没有在全球范围内安装此软件,但是无论是否使用它我都尝试过并得到相同的错误。

我安装了xcode 9.1并运行:
$ xcode-select --install
给出:xcode-select: error: command line tools are already installed, use "Software Update" to install updates

我遵循以下步骤:npmjs.com/fixing-npm-permissions

$ gcc --version
这使:

Configured with: --prefix=/Applications/Xcode.app/Contents/Developer/usr --with-gxx-include-dir=/usr/include/c++/4.2.1
Apple LLVM version 9.0.0 (clang-900.0.38)
Target: x86_64-apple-darwin16.7.0
Thread model: posix
InstalledDir: /Applications/Xcode.app/Contents/Developer/Toolchains/XcodeDefault.xctoolchain/usr/bin


$ which gcc
这使:
/usr/bin/gcc

node-gyp问题使我认为它与编译器有关,但是我已经重新安装了xcode和node(通过brew和nodejs.org)。

任何帮助或建议,将不胜感激。

编辑:

我尝试了npm 3.10.10,因为5.6.0显然不合适。这是以前安装的,无法解决问题。

我安装了xcode 8.2.1来替换xcode 9.1,但这不能解决问题。

最佳答案

基本上,您需要安装libtool使其起作用。这是我使用bcrypt时遇到的相同问题。如果这似乎不起作用,则应查看this

另外,请根据node-gyp文档检查是否安装了哪个python版本,支持的版本是2.7,最新版本3.x尚不支持。此node Js Workshop讨论有关gyp的更多详细信息,这也应有所帮助。

10-07 12:59
查看更多