【问题标题】:node-gyp rebuild fails on Mac OS High Sierra while npm install在 npm install 时,node-gyp 重建在 Mac OS High Sierra 上失败
【发布时间】:2019-04-05 08:07:06
【问题描述】:

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

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

【问题讨论】:

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


    【解决方案1】:

    Luke 提到的上述解决方案部分为我工作(MacOS),但产生了另一个问题: gyp ERR! stack Error:makefailed with exit code: 2 已通过删除锁定的 json 文件解决。问题是由于 MAC OS 中的许可而创建的。因此,如果您已经重新安装了 xcode,请打开终端(命令行)并输入:

    xcode-select --reset
    

    然后转到您的项目文件夹并删除: package-lock.json 现在在终端重新安装项目:

    npm install
    

    我希望这对某人有帮助!

    【讨论】:

    • 我的建议是我的情况(它发生在我身上并且如上所述解决了)。所以这不是猜测。请留下评论是你要留下反对票,所以我知道你为什么这样做,如果你有理由删除我的评论。否则,我们会误导可能与我的情况完全相同的人。
    【解决方案2】:

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

    按照以下步骤在 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”。 构建之后立即开始工作,没有任何问题。

    【讨论】:

      猜你喜欢
      • 2012-08-20
      • 2015-03-28
      • 1970-01-01
      • 2022-01-16
      • 2014-12-04
      • 2016-05-19
      • 1970-01-01
      • 1970-01-01
      • 2020-09-11
      相关资源
      最近更新 更多