Node.js 节点libcurl在MacOS Catalina上安装失败:clang:error:没有这样的文件或目录:'/usr/include';

Node.js 节点libcurl在MacOS Catalina上安装失败:clang:error:没有这样的文件或目录:'/usr/include';,node.js,macos,npm,libcurl,node-libcurl,Node.js,Macos,Npm,Libcurl,Node Libcurl,我只是想在依赖于的Mac(Catalina)上安装,但出现以下错误: npm install -g node-libcurl > node-libcurl@2.2.0 install /Users/jonashecht/dev/spring-boot/spring-boot-openapi-kong/node_modules/node-libcurl > node-pre-gyp install --fallback-to-build node-pre-gyp WARN Usin

我只是想在依赖于的Mac(Catalina)上安装,但出现以下错误:

npm install -g node-libcurl

> node-libcurl@2.2.0 install /Users/jonashecht/dev/spring-boot/spring-boot-openapi-kong/node_modules/node-libcurl
> node-pre-gyp install --fallback-to-build

node-pre-gyp WARN Using request for node-pre-gyp https download
  CXX(target) Release/obj.target/node_libcurl/src/node_libcurl.o
clang: error: no such file or directory: '/usr/include'
make: *** [Release/obj.target/node_libcurl/src/node_libcurl.o] 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:194:23)
gyp ERR! stack     at ChildProcess.emit (node:events:327:20)
gyp ERR! stack     at Process.ChildProcess._handle.onexit (node:internal/child_process:277:12)
gyp ERR! System Darwin 19.6.0
gyp ERR! command "/usr/local/Cellar/node/15.1.0/bin/node" "/usr/local/lib/node_modules/npm/node_modules/node-gyp/bin/node-gyp.js" "build" "--fallback-to-build" "--module=/Users/jonashecht/dev/spring-boot/spring-boot-openapi-kong/node_modules/node-libcurl/lib/binding/node_libcurl.node" "--module_name=node_libcurl" "--module_path=/Users/jonashecht/dev/spring-boot/spring-boot-openapi-kong/node_modules/node-libcurl/lib/binding" "--napi_version=7" "--node_abi_napi=napi" "--napi_build_version=0" "--node_napi_label=node-v88"
gyp ERR! cwd /Users/jonashecht/dev/spring-boot/spring-boot-openapi-kong/node_modules/node-libcurl
gyp ERR! node -v v15.1.0
gyp ERR! node-gyp -v v5.1.0
gyp ERR! not ok
node-pre-gyp ERR! build error
node-pre-gyp ERR! stack Error: Failed to execute '/usr/local/Cellar/node/15.1.0/bin/node /usr/local/lib/node_modules/npm/node_modules/node-gyp/bin/node-gyp.js build --fallback-to-build --module=/Users/jonashecht/dev/spring-boot/spring-boot-openapi-kong/node_modules/node-libcurl/lib/binding/node_libcurl.node --module_name=node_libcurl --module_path=/Users/jonashecht/dev/spring-boot/spring-boot-openapi-kong/node_modules/node-libcurl/lib/binding --napi_version=7 --node_abi_napi=napi --napi_build_version=0 --node_napi_label=node-v88' (1)
node-pre-gyp ERR! stack     at ChildProcess.<anonymous> (/Users/jonashecht/dev/spring-boot/spring-boot-openapi-kong/node_modules/node-pre-gyp/lib/util/compile.js:83:29)
node-pre-gyp ERR! stack     at ChildProcess.emit (node:events:327:20)
node-pre-gyp ERR! stack     at maybeClose (node:internal/child_process:1055:16)
node-pre-gyp ERR! stack     at Process.ChildProcess._handle.onexit (node:internal/child_process:288:5)
node-pre-gyp ERR! System Darwin 19.6.0
node-pre-gyp ERR! command "/usr/local/Cellar/node/15.1.0/bin/node" "/Users/jonashecht/dev/spring-boot/spring-boot-openapi-kong/node_modules/.bin/node-pre-gyp" "install" "--fallback-to-build"
node-pre-gyp ERR! cwd /Users/jonashecht/dev/spring-boot/spring-boot-openapi-kong/node_modules/node-libcurl
node-pre-gyp ERR! node -v v15.1.0
node-pre-gyp ERR! node-pre-gyp -v v0.15.0
node-pre-gyp ERR! not ok
Failed to execute '/usr/local/Cellar/node/15.1.0/bin/node /usr/local/lib/node_modules/npm/node_modules/node-gyp/bin/node-gyp.js build --fallback-to-build --module=/Users/jonashecht/dev/spring-boot/spring-boot-openapi-kong/node_modules/node-libcurl/lib/binding/node_libcurl.node --module_name=node_libcurl --module_path=/Users/jonashecht/dev/spring-boot/spring-boot-openapi-kong/node_modules/node-libcurl/lib/binding --napi_version=7 --node_abi_napi=napi --napi_build_version=0 --node_napi_label=node-v88' (1)

npm ERR! code ELIFECYCLE
npm ERR! errno 1
npm ERR! node-libcurl@2.2.0 install: `node-pre-gyp install --fallback-to-build`
npm ERR! Exit status 1
npm ERR!
npm ERR! Failed at the node-libcurl@2.2.0 install script.
npm ERR! This is probably not a problem with npm. There is likely additional logging output above.

npm ERR! A complete log of this run can be found in:
npm ERR!     /Users/jonashecht/.npm/_logs/2020-11-05T08_43_46_342Z-debug.log

这个问题来自最新MacOS版本上较新版本的Xcode命令行工具

日志中的关键部分是:

  CXX(target) Release/obj.target/node_libcurl/src/node_libcurl.o
clang: error: no such file or directory: '/usr/include'
make: *** [Release/obj.target/node_libcurl/src/node_libcurl.o] Error 1
作为:

命令行工具的较新版本不添加/usr/include 默认情况下为文件夹。查看详细信息

为了解决这个问题,我们需要通过设置npm环境变量
npm\u config\u curl\u include\dirs
来告诉
npm install
有关
/usr/include
的新位置,即
$(xcrun--show sdk path)/usr/include
,如下所示:

npm_config_curl_include_dirs="$(xcrun --show-sdk-path)/usr/include" npm install -g node-libcurl
在我的例子中,我想首先安装另一个npm库,如
inso
,您需要将两个npm库添加到命令中,以便成功安装:

npm_config_curl_include_dirs="$(xcrun --show-sdk-path)/usr/include" npm install -g node-libcurl insomnia-inso
现在,安装
失眠保险系统
的工作非常出色

npm_config_curl_include_dirs="$(xcrun --show-sdk-path)/usr/include" npm install -g node-libcurl insomnia-inso