尝试将bcrypt安装到节点项目+节点设置问题

时间:2014-12-27 07:50:31

标签: node.js npm mean

我见过一些非常相似的问题,但我找不到任何问题似乎都有效。我正在尝试npm安装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

7 个答案:

答案 0 :(得分:43)

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

如果没有一件事可以解决问题,请告诉我,我会尽力提供帮助。

答案 1 :(得分:3)

如果01:03对您不起作用,请尝试重新安装xcode:

sudo xcode-select --switch $(xcode-select -print-path)

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

答案 2 :(得分: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

希望这对以后的人有帮助。

答案 3 :(得分:2)

我设法通过打开Xcode,转到“首选项”->“位置”->“命令行工具”,然后从下拉菜单中选择它(之前为空)来解决此问题。

enter image description here

答案 4 :(得分:1)

遵循这些步骤有助于我在MacOS上解决此问题

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

  • xcode-select --install

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

  • sudo npm install -g node-gyp

答案 5 :(得分:0)

我有一个类似的问题。最后解决起来很简单。 只需运行

xcode-select --install

先安装最新工具,然后

sudo xcodebuild -license

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

答案 6 :(得分:0)

在终端上安装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