trying to install bcrypt into node project + node set up issues

ReganPerkins picture ReganPerkins · Dec 27, 2014 · Viewed 20.2k times · Source

I have seen some very similar questions but none that I have found seem to work. I am trying to npm install bcrypt but i keep getting the error below.

bycrypt is the command that I use to install bcrypt modules. I do have Xcode and installing node-gyp does not seem to make a difference

regan@the-Voyagur buddha-bar (feature/styles) $ npm install --save bcrypt
npm WARN package.json [email protected] No repository field.
npm WARN package.json [email protected] No README data
-
> [email protected] 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! [email protected] install: `node-gyp rebuild`
npm ERR! Exit status 1
npm ERR!
npm ERR! Failed at the [email protected] 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

Answer

Sam Mikes picture Sam Mikes · Dec 27, 2014

OP managed to fix this for themselves with:

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

but graciously accepted my answer anyway.

Original answer below:

There are two distinct problems here. One is that your node is slightly out of date and your npm is substantially out of date.

You're using OSX, so there are a number of popular ways to manage different node versions. Here's a guide on updating node https://github.com/npm/npm/wiki/Troubleshooting#updating-node-on-osx

Then you'll want to update to the latest npm:

npm install -g npm@latest

Finally, it looks like although you have XCode installed, something is still awry. You report that this command yields

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

On my system, which is OSX/Yosemite and can build native addon modules, I see

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

You may need to switch your xcode path to a different directory. For starters, though, please update to the current node and npm tools and try the installation again; if it still fails, the least dangerous next thing to try is

xcode-select --install

If none of that fixes things, let me know and I'll try to help further.