node-gyp重build问题编译器
这个问题似乎并不是我的所有项目的情况,特别是当我运行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)
任何帮助或build议将非常感激。
编辑:
我试过npm 3.10.10,因为5.6.0显然不对。 这是以前安装,并没有解决问题。
我安装了xcode 8.2.1来replacexcode 9.1,但这并没有解决问题。
你基本上需要安装libtool
使其工作。 这是我使用bcrypt
时遇到的问题。 如果这似乎不工作,你应该看看这个 。
另外请检查安装了哪个版本的python,支持的版本是2.7,最新的3.x版本还不支持按照node-gyp文档。 Js Workshop的这个节点讨论关于gyp的更多细节,这也应该有一些帮助。
我不完全确定解决scheme是什么。
- 我安装了xcode 8.2.1(从9.1开始)。 我曾尝试过,但最初这不起作用。
- 然后我手动安装了commandlinetools(不是通过
xcode-select --install
)(在安装之前或之后Library/Developer/CommandLineTools
不存在) –xcode-select -p
从指向xcode到commandlinetools的path改变了,目录不存在。 - 然后我再次安装Xcode8.2.1,xcode-select的path自动更改而不需要重置(xcode-select –reset)
之后,我的问题就解决了。