Failing to install node.js SDK on ubuntu 15.04

Just trying to follow these instructions. Here’s what I did:

sudo apt-get update
sudo apt-get install nodejs
sudo apt-get install npm

Those all installed fine. Then I did:

sudo npm install -g node-gyp

and the message was:

npm WARN engine hawk@3.1.0: wanted: {"node":">=0.10.32"} (current: {"node":"0.10.25","npm":"1.4.21"})
/usr/local/bin/node-gyp -> /usr/local/lib/node_modules/node-gyp/bin/node-gyp.js
node-gyp@2.0.2 /usr/local/lib/node_modules/node-gyp
├── graceful-fs@3.0.8
├── osenv@0.1.3 (os-tmpdir@1.0.1, os-homedir@1.0.1)
├── nopt@3.0.3 (abbrev@1.0.7)
├── which@1.1.1 (is-absolute@0.1.7)
├── fstream@1.0.7 (inherits@2.0.1)
├── minimatch@1.0.0 (sigmund@1.0.1, lru-cache@2.6.5)
├── semver@4.3.6
├── mkdirp@0.5.1 (minimist@0.0.8)
├── path-array@1.0.0 (array-index@0.1.1)
├── tar@1.0.3 (inherits@2.0.1, block-stream@0.0.8)
├── glob@4.5.3 (inherits@2.0.1, once@1.3.2, inflight@1.0.4, minimatch@2.0.10)
├── rimraf@2.4.2 (glob@5.0.14)
├── npmlog@1.2.1 (ansi@0.3.0, are-we-there-yet@1.0.4, gauge@1.2.2)
└── request@2.60.0 (aws-sign2@0.5.0, forever-agent@0.6.1, caseless@0.11.0, stringstream@0.0.4, tunnel-agent@0.4.1, oau
th-sign@0.8.0, isstream@0.1.2, json-stringify-safe@5.0.1, extend@3.0.0, node-uuid@1.4.3, combined-stream@1.0.5, qs@4.0
.0, form-data@1.0.0-rc2, mime-types@2.1.3, http-signature@0.11.0, bl@1.0.0, tough-cookie@2.0.0, har-validator@1.8.0, h
awk@3.1.0)

Small warning, but whatever, let’s proceed.

sudo npm install couchbase

Which says…

-
> couchbase@2.0.10 install /home/dbergan/node_modules/couchbase
> (node-gyp rebuild 2> builderror.log) || (exit 0)
couchbase@2.0.10 node_modules/couchbase
├── bindings@1.2.1
├── jsonparse@1.0.0
├── nan@1.8.4
└── request@2.58.0 (caseless@0.10.0, aws-sign2@0.5.0, forever-agent@0.6.1, stringstream@0.0.4, tunnel-agent@0.4.1, oau
th-sign@0.8.0, isstream@0.1.2, extend@2.0.1, json-stringify-safe@5.0.1, node-uuid@1.4.3, combined-stream@1.0.5, qs@3.1
.0, mime-types@2.0.14, http-signature@0.11.0, form-data@1.0.0-rc2, bl@0.9.4, tough-cookie@2.0.0, hawk@2.3.1, har-valid
ator@1.8.0)

What’s that “node-gyp rebuild 2> builderror.log” message?

vi node_modules/couchbase/builderror.log

/bin/sh: 1: node: not found
gyp: Call to 'node -e "require('nan')"' returned exit status 127. while trying to load binding.gyp
gyp ERR! configure error
gyp ERR! stack Error: `gyp` failed with exit code: 1
gyp ERR! stack     at ChildProcess.onCpExit (/usr/share/node-gyp/lib/configure.js:344:16)
gyp ERR! stack     at ChildProcess.EventEmitter.emit (events.js:98:17)
gyp ERR! stack     at Process.ChildProcess._handle.onexit (child_process.js:797:12)
gyp ERR! System Linux 3.19.0-25-generic
gyp ERR! command "nodejs" "/usr/bin/node-gyp" "rebuild"
gyp ERR! cwd /home/dbergan/node_modules/couchbase
gyp ERR! node -v v0.10.25
gyp ERR! node-gyp -v v0.12.2
gyp ERR! not ok

And when I run this most basic .js:

var couchbase = require("couchbase") ;

It fails miserably:

---
build errors (/home/dbergan/node_modules/couchbase/lib/../builderror.log):
---
/bin/sh: 1: node: not found
gyp: Call to 'node -e "require('nan')"' returned exit status 127. while trying to load binding.gyp
gyp ERR! configure error 
gyp ERR! stack Error: `gyp` failed with exit code: 1
gyp ERR! stack     at ChildProcess.onCpExit (/usr/share/node-gyp/lib/configure.js:344:16)
gyp ERR! stack     at ChildProcess.EventEmitter.emit (events.js:98:17)
gyp ERR! stack     at Process.ChildProcess._handle.onexit (child_process.js:797:12)
gyp ERR! System Linux 3.19.0-25-generic
gyp ERR! command "nodejs" "/usr/bin/node-gyp" "rebuild"
gyp ERR! cwd /home/dbergan/node_modules/couchbase
gyp ERR! node -v v0.10.25
gyp ERR! node-gyp -v v0.12.2
gyp ERR! not ok 
---
load exceptions:
---
`couchbase_impl`:
{ [Error: Could not locate the bindings file. Tried:
 → /home/dbergan/node_modules/couchbase/build/couchbase_impl.node
 → /home/dbergan/node_modules/couchbase/build/Debug/couchbase_impl.node
 → /home/dbergan/node_modules/couchbase/build/Release/couchbase_impl.node
 → /home/dbergan/node_modules/couchbase/out/Debug/couchbase_impl.node
 → /home/dbergan/node_modules/couchbase/Debug/couchbase_impl.node
 → /home/dbergan/node_modules/couchbase/out/Release/couchbase_impl.node
 → /home/dbergan/node_modules/couchbase/Release/couchbase_impl.node
 → /home/dbergan/node_modules/couchbase/build/default/couchbase_impl.node
 → /home/dbergan/node_modules/couchbase/compiled/0.10.25/linux/x64/couchbase_impl.node]
  tries: 
   [ '/home/dbergan/node_modules/couchbase/build/couchbase_impl.node',
     '/home/dbergan/node_modules/couchbase/build/Debug/couchbase_impl.node',
     '/home/dbergan/node_modules/couchbase/build/Release/couchbase_impl.node',
     '/home/dbergan/node_modules/couchbase/out/Debug/couchbase_impl.node',
     '/home/dbergan/node_modules/couchbase/Debug/couchbase_impl.node',
     '/home/dbergan/node_modules/couchbase/out/Release/couchbase_impl.node',
     '/home/dbergan/node_modules/couchbase/Release/couchbase_impl.node',
     '/home/dbergan/node_modules/couchbase/build/default/couchbase_impl.node',
     '/home/dbergan/node_modules/couchbase/compiled/0.10.25/linux/x64/couchbase_impl.node' ] }
---
/home/dbergan/node_modules/couchbase/lib/binding.js:188
  throw new Error('Failed to locate couchnode native binding' +
        ^
Error: Failed to locate couchnode native binding (see above for more information!)
    at Object.<anonymous> (/home/dbergan/node_modules/couchbase/lib/binding.js:188:9)
    at Module._compile (module.js:456:26)
    at Object.Module._extensions..js (module.js:474:10)
    at Module.load (module.js:356:32)
    at Function.Module._load (module.js:312:12)
    at Module.require (module.js:364:17)
    at require (module.js:380:17)
    at Object.<anonymous> (/home/dbergan/node_modules/couchbase/lib/couchbase.js:3:15)
    at Module._compile (module.js:456:26)
    at Object.Module._extensions..js (module.js:474:10)

What am I doing wrong?

Kind regards,
David

I would fix the first error first and go from there. I try to avoid installing secondary package managers like bower and NPM from any stock/official Debian based repository, unless it is a backport repo. They are always outdated. Try https://github.com/nodesource/distributions

Hey dbergan,

The error in builderror.log indicates that node is not on your path (I suspect that it was installed under a different name by your package manage, as mentioned by cloudrck). Try to symlink node to the name as installed by the package manager, or simply install node through normal channels.

Cheers, Brett

Thanks for the help! For anyone else who has this trouble, here are the exact commands I used from a fresh install.

curl -sL https://deb.nodesource.com/setup_0.12 | sudo -E bash -
sudo apt-get update
sudo apt-get install build-essential
sudo apt-get install -y nodejs
sudo apt-get install npm
sudo npm install -g node-gyp
sudo npm install couchbase

Kind regards,
David