node.js - npm 安装时 node-gyp 重建在 Mac OS High Sierra 上失败

标签 node.js macos npm npm-install node-gyp

我在终端中遇到以下错误,同时它尝试安装包“node-expat”之一。我尝试使用 nvm 切换到不同的 Node 版本,但它仍然失败并出现相同的错误。

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/node-expat
npm ERR! node v6.5.0
npm ERR! npm  v3.10.3
npm ERR! code ELIFECYCLE
npm ERR! node-expat@2.0.0 install: `node-gyp rebuild`
npm ERR! Exit status 1
npm ERR!
npm ERR! Failed at the node-expat@2.0.0 install script 'node-gyp rebuild'.
npm ERR! Make sure you have the latest version of node.js and npm installed.
npm ERR! If you do, this is most likely a problem with the node-expat package,
npm ERR! not with npm itself.
npm ERR! Tell the author that this fails on your system:
npm ERR!     node-gyp rebuild
npm ERR! You can get information on how to open an issue for this project with:
npm ERR!     npm bugs node-expat
npm ERR! Or if that isn't available, you can get their info via:
npm ERR!     npm owner ls node-expat
npm ERR! There is likely additional logging output above.

npm ERR! Please include the following file with any support request:
npm ERR!     c:\<redacted>\npm-debug.log

我继续按照 git hub 页面上的建议在我的机器上安装 x-code,然后出现以下错误。不确定如何进一步调试。

xcode-select: error: tool 'xcodebuild' requires Xcode, 
but active developer directory '/Library/Developer/CommandLineTools' is a command line tools instance

最佳答案

我刚刚在我的机器和同事的机器上修复了它。

按照以下步骤在 MacOS highSierra 10.13 上修复它:

  1. 下载并安装了适用于 xcode 的命令行工具 (MacOS 10.13)。 从“https://developer.apple.com/download/more/”下载
  2. 从应用商店安装了 xcode 10.0。打开 xcode 并完成 xcode 在初始启动时进行的常规配置。
  3. 在此之后,它开始出现上述描述中所述的“xcode-select”路径问题。在运行命令“xcode-select --print-path”时,它显示路径为“/Library/Developer/CommandLineTools”,所以我继续尝试“xcode-select --reset ”,之后路径更改为“/Applications/Xcode.app/Contents/Developer”。 紧随其后,构建开始正常运行。

关于node.js - npm 安装时 node-gyp 重建在 Mac OS High Sierra 上失败,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/53095533/

相关文章:

node.js - Node LTS 8.9.0 上的 Node 检查器错误

javascript - NodeJS 中的 Promise 和函数没有返回任何内容

ios - 我需要使用 Xcode 的 Image.xcassets 新图像集和新 OSX 图标吗

java - 为什么 dtruss 不显示此 JNI 代码中的 select 系统调用?

macos - ~/.npm 目录是干什么用的?

node.js - 如何将nodeJS docker容器连接到mongoDB

objective-c - 用于发送电子邮件的脚本桥 - 错误 : Object not added to container yet

javascript - 将reactjs组件作为 Node 模块导出到npm时,我是否包含jsx或js

node.js - 为 Atom 开发包时 Node 模块版本冲突

javascript - DiscordJS 语音 channel 信息不更新