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

Reg*_*ins 17 mean node.js npm

我见过一些非常相似的问题,但我找不到任何问题似乎都有效.我正在尝试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
Run Code Online (Sandbox Code Playgroud)

Sam*_*kes 45

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

如果没有解决问题,请告诉我,我会尽力帮助.

  • 实际上你建议用这行修改它`sudo xcode-select -switch/Applications/Xcode.app/Contents/Developer /` (3认同)

got*_*to1 9

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

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
Run Code Online (Sandbox Code Playgroud)

运行macOS Catalina 10.15.2,我尝试了以下操作:

$ xcode-select --install
xcode-select: error: command line tools are already installed, 
use "Software Update" to install updates
Run Code Online (Sandbox Code Playgroud)

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

$ [sudo] xcode-select --reset
Run Code Online (Sandbox Code Playgroud)

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


编辑

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