12

在 macOS (Mojave) 上运行yarn installNode 6.11.1 项目时,node-gyp rebuildforhiredis失败:

XCode 命令行工具已通过sudo xcode-select --install.

节点是通过nvm.

error /Users/alexzeitler/src/some-project/node_modules/hiredis: Command failed.
Exit code: 1
Command: node-gyp rebuild
Arguments:
Directory: /Users/alexzeitler/src/some-project/node_modules/hiredis
Output:
gyp info it worked if it ends with ok
gyp info using node-gyp@3.4.0
gyp info using node@6.11.1 | darwin | x64
gyp WARN download NVM_NODEJS_ORG_MIRROR is deprecated and will be removed in node-gyp v4, please use NODEJS_ORG_MIRROR
gyp WARN download NVM_NODEJS_ORG_MIRROR is deprecated and will be removed in node-gyp v4, please use NODEJS_ORG_MIRROR
gyp info spawn /usr/bin/python
gyp info spawn args [ '/Users/alexzeitler/.nvm/versions/node/v6.11.1/lib/node_modules/npm/node_modules/node-gyp/gyp/gyp_main.py',
gyp info spawn args   'binding.gyp',
gyp info spawn args   '-f',
gyp info spawn args   'make',
gyp info spawn args   '-I',
gyp info spawn args   '/Users/alexzeitler/src/some-project/node_modules/hiredis/build/config.gypi',
gyp info spawn args   '-I',
gyp info spawn args   '/Users/alexzeitler/.nvm/versions/node/v6.11.1/lib/node_modules/npm/node_modules/node-gyp/addon.gypi',
gyp info spawn args   '-I',
gyp info spawn args   '/Users/alexzeitler/.node-gyp/6.11.1/include/node/common.gypi',
gyp info spawn args   '-Dlibrary=shared_library',
gyp info spawn args   '-Dvisibility=default',
gyp info spawn args   '-Dnode_root_dir=/Users/alexzeitler/.node-gyp/6.11.1',
gyp info spawn args   '-Dnode_gyp_dir=/Users/alexzeitler/.nvm/versions/node/v6.11.1/lib/node_modules/npm/node_modules/node-gyp',
gyp info spawn args   '-Dnode_lib_file=node.lib',
gyp info spawn args   '-Dmodule_root_dir=/Users/alexzeitler/src/some-project/node_modules/hiredis',
gyp info spawn args   '--depth=.',
gyp info spawn args   '--no-parallel',
gyp info spawn args   '--generator-output',
gyp info spawn args   'build',
gyp info spawn args   '-Goutput_dir=.' ]
gyp WARN download NVM_NODEJS_ORG_MIRROR is deprecated and will be removed in node-gyp v4, please use NODEJS_ORG_MIRROR
gyp info spawn make
gyp info spawn args [ 'BUILDTYPE=Release', '-C', 'build' ]
  CC(target) Release/obj.target/hiredis-c/deps/hiredis/sds.o
  CC(target) Release/obj.target/hiredis-c/deps/hiredis/read.o
  LIBTOOL-STATIC Release/hiredis-c.a
  CXX(target) Release/obj.target/hiredis/src/hiredis.o
warning: include path for stdlibc++ headers not found; pass '-std=libc++' on the command line to use the libc++ standard library instead [-Wstdlibcxx-not-found]
In file included from ../src/hiredis.cc:1:
In file included from ../src/reader.h:1:
In file included from ../../nan/nan.h:51:
In file included from /Users/alexzeitler/.node-gyp/6.11.1/include/node/node.h:42:
/Users/alexzeitler/.node-gyp/6.11.1/include/node/v8.h:21:10: fatal error: 'utility' file not found
#include <utility>
         ^~~~~~~~~
1 warning and 1 error generated.
make: *** [Release/obj.target/hiredis/src/hiredis.o] Error 1
gyp ERR! build error
gyp ERR! stack Error: `make` failed with exit code: 2
gyp ERR! stack     at ChildProcess.onExit (/Users/alexzeitler/.nvm/versions/node/v6.11.1/lib/node_modules/npm/node_modules/node-gyp/lib/build.js:276:23)
gyp ERR! stack     at emitTwo (events.js:106:13)
gyp ERR! stack     at ChildProcess.emit (events.js:191:7)
gyp ERR! stack     at Process.ChildProcess._handle.onexit (internal/child_process.js:215:12)
gyp ERR! System Darwin 18.0.0
gyp ERR! command "/Users/alexzeitler/.nvm/versions/node/v6.11.1/bin/node" "/Users/alexzeitler/.nvm/versions/node/v6.11.1/lib/node_modules/npm/node_modules/node-gyp/bin/node-gyp.js" "rebuild"
gyp ERR! cwd /Users/alexzeitler/src/some-project/node_modules/hiredis
gyp ERR! node -v v6.11.1
gyp ERR! node-gyp -v v3.4.0
gyp ERR! not ok

更新:通过nvm一切正常使用节点 8.11.1(但在这个特定项目中还不能选择迁移到 8.11.1)。

4

3 回答 3

26

这为我修复了它:

CXXFLAGS="-mmacosx-version-min=10.9" LDFLAGS="-mmacosx-version-min=10.9" yarn

从这里尝试了答案。

于 2018-10-05T22:33:13.537 回答
15

如果您使用的是 XCode 10,您会注意到,如果您导航到/usr,您将不会再看到一个名为的文件夹include,这就是终端抱怨缺少包含在“include”文件夹中的头文件的原因。

  1. 这里然后下载并安装:Command Line Tools (macOS 10.14) for Xcode 10
  2. 打开~/../../Library/Developer/CommandLineTools/Packages/macOS_SDK_headers_for_macOS_10.14.pkg
  3. CXXFLAGS="-mmacosx-version-min=10.9" LDFLAGS="-mmacosx-version-min=10.9" yarn install

那么你应该很高兴。

于 2018-10-03T18:39:39.703 回答
0

曾经在 Linux 平台上遇到过同样的问题。从家中删除node_modules和目录修复了错误。.node-gyp/

于 2018-10-05T19:30:13.647 回答