【问题标题】:trying to install bcrypt into node project + node set up issues尝试将 bcrypt 安装到节点项目 + 节点设置问题
【发布时间】:2015-02-24 06:08:00
【问题描述】:

我看到了一些非常相似的问题,但我发现没有一个似乎有效。我正在尝试 npm install bcrypt 但我不断收到以下错误。

bycrypt 是我用来安装 bcrypt 模块的命令。我确实有 Xcode,安装 node-gyp 似乎没有什么不同

regan@the-Voyagur buddha-bar (feature/styles) $ npm install --save bcrypt
npm WARN package.json mongo@0.1.0 No repository field.
npm WARN package.json mongo@0.1.0 No README data
-
> bcrypt@0.8.0 install /Users/regan/lighthouse/buddha-bar/node_modules/bcrypt
> node-gyp rebuild

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

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

No receipt for 'com.apple.pkg.CLTools_Executables' found at '/'.

No receipt for 'com.apple.pkg.DeveloperToolsCLILeo' found at '/'.

No receipt for 'com.apple.pkg.DeveloperToolsCLI' found at '/'.

gyp: No Xcode or CLT version detected!
gyp ERR! configure error
gyp ERR! stack Error: `gyp` failed with exit code: 1
gyp ERR! stack     at ChildProcess.onCpExit (/usr/local/lib/node_modules/npm/node_modules/node-gyp/lib/configure.js:343:16)
gyp ERR! stack     at ChildProcess.emit (events.js:98:17)
gyp ERR! stack     at Process.ChildProcess._handle.onexit (child_process.js:810:12)
gyp ERR! System Darwin 14.0.0
gyp ERR! command "node" "/usr/local/lib/node_modules/npm/node_modules/node-gyp/bin/node-gyp.js" "rebuild"
gyp ERR! cwd /Users/regan/lighthouse/buddha-bar/node_modules/bcrypt
gyp ERR! node -v v0.10.33
gyp ERR! node-gyp -v v1.0.1
gyp ERR! not ok

npm ERR! bcrypt@0.8.0 install: `node-gyp rebuild`
npm ERR! Exit status 1
npm ERR!
npm ERR! Failed at the bcrypt@0.8.0 install script.
npm ERR! This is most likely a problem with the bcrypt 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 their info via:
npm ERR!     npm owner ls bcrypt
npm ERR! There is likely additional logging output above.
npm ERR! System Darwin 14.0.0
npm ERR! command "node" "/usr/local/bin/npm" "install" "--save" "bcrypt"
npm ERR! cwd /Users/regan/lighthouse/buddha-bar
npm ERR! node -v v0.10.33
npm ERR! npm -v 1.4.28
npm ERR! code ELIFECYCLE
npm ERR! not ok code 0
regan@the-Voyagur buddha-bar (feature/styles) $ xcode-select --print-path
/Library/Developer/CommandLineTools

【问题讨论】:

标签: node.js npm mean


【解决方案1】:

OP 设法自己解决了这个问题:

sudo xcode-select -switch /Applications/Xcode.app/Contents/Developer/

不过还是很客气地接受了我的回答。

原答案如下:

这里有两个明显的问题。一是您的node 稍微过时了,而您的npm 基本上过时了。

您使用的是 OSX,因此有许多流行的方法来管理不同的节点版本。这是更新节点https://github.com/npm/npm/wiki/Troubleshooting#updating-node-on-osx的指南

然后你要更新到最新的npm

npm install -g npm@latest

最后,看起来虽然您安装了 XCode,但还是有问题。您报告此命令产生

$ xcode-select --print-path /Library/Developer/CommandLineTools

在我的 OSX/Yosemite 系统上,可以构建原生插件模块,我明白了

$ xcode-select --print-path /Applications/Xcode.app/Contents/Developer

您可能需要将您的 xcode 路径切换到不同的目录。不过,对于初学者,请更新到当前的nodenpm 工具并再次尝试安装;如果它仍然失败,接下来要尝试的最危险的事情是

xcode-select --install

如果这些都不能解决问题,请告诉我,我会尽力提供进一步帮助。

【讨论】:

  • 嘿 Sam 感谢您的帮助,我已将 node 和 npm 更新到最新版本并尝试运行 xcode-select --install 但没有运气。我得到这个 regan@the-Voyagur buddha-bar (feature/styles) $ xcode-select --install xcode-select: error: 命令行工具已经安装,使用“软件更新”来安装更新
  • 实际上你建议的这条线修复了它sudo xcode-select -switch /Applications/Xcode.app/Contents/Developer/
  • 我没有 xcode 命令行工具,所以运行命令 xcode-select --install 解决了问题
【解决方案2】:

我遇到了类似的问题,但使用了不同的包。

node-gyp rebuild
No receipt for 'com.apple.pkg.CLTools_Executables' found at '/'.
No receipt for 'com.apple.pkg.DeveloperToolsCLILeo' found at '/'.
No receipt for 'com.apple.pkg.DeveloperToolsCLI' found at '/'.
gyp: No Xcode or CLT version detected!
gyp ERR! configure error

运行macOS Catalina 10.15.2,我尝试了以下方法:

$ xcode-select --install
xcode-select: error: command line tools are already installed, 
use "Software Update" to install updates

通过执行以下操作修复它:

$ [sudo] xcode-select --reset

希望这对将来的某人有所帮助。


编辑

如果有人仍然遇到问题,GitHub 上有一个帖子有其他值得尝试的解决方案:

【讨论】:

【解决方案3】:

我有一个类似的问题。最终解决它很简单。 只好跑了

xcode-select --install

安装最新的工具,然后

sudo xcodebuild -license

同意新的许可条款。之后 bcrypt 安装没有任何问题。

【讨论】:

    【解决方案4】:

    如果sudo xcode-select --switch $(xcode-select -print-path)对你不起作用,请尝试重新安装xcode:

    $ sudo rm -rf $(xcode-select -print-path)
    $ xcode-select --install
    

    查看更多:https://github.com/nodejs/node-gyp/issues/569

    【讨论】:

      【解决方案5】:

      我设法解决了这个问题,方法是打开 Xcode,转到首选项 -> 位置 -> 命令行工具,然后从下拉列表中选择它(之前它是空的)。

      【讨论】:

      • 尝试了很多到处提到的命令,最后这对我有用。
      【解决方案6】:

      按照这些步骤帮助我在 MacOS 上解决了这个问题

      • sudo rm -rf $(xcode-select -print-path)

      • xcode-select --install

      • /usr/sbin/pkgutil --packages | grep CL

      • sudo npm install -g node-gyp

      【讨论】:

        【解决方案7】:

        在终端上从(我更喜欢)https://developer.apple.com/download/more/xcode-select --install 安装 xcode。

        然后按照顺序。

        sudo xcode-select -s /Applications/Xcode.app/Contents/Developer
        sudo xcodebuild -license
        /usr/sbin/pkgutil --packages | grep CL
        sudo npm install -g node-gyp
        

        【讨论】:

          猜你喜欢
          • 1970-01-01
          • 1970-01-01
          • 2021-06-29
          • 1970-01-01
          • 1970-01-01
          • 1970-01-01
          • 1970-01-01
          • 1970-01-01
          • 2014-11-27
          相关资源
          最近更新 更多