title: Failed to load c++ bson extension, using pure JS version -- no mongoose, no express, just node driver
body: <p>I worked through a very simple mongodb tutorial in which we used the mongo shell to create a db, create a collection, and then wrote a very simple nodejs program to access the collection and log the documents to the console.</p>
  
  <pre><code>var mongodb = require('mongodb');
  
  var db = new mongodb.Db('mcfly', new mongodb.Server('127.0.0.1', 27017), {safe: true});
  
  db.open(function(err) {
    db.collection('mathpeeps', function(err, collection){
      collection.find().toArray(function(err, items){
    console.log(items)
      });
    });
  });
  </code></pre>
  
  <p>But when I run the program it gives me:</p>
  
  <pre><code>js-bson: Failed to load c++ bson extension, using pure JS version
  [ { _id: 53ab29bbdb49942ae25b5201,
      firstname: 'Leonard',
      lastname: 'Euler',
      born: 1707 },
    { _id: 53ab29fedb49942ae25b5202,
      firstname: 'Karl',
      lastname: 'Gauss' } ]
  </code></pre>
  
  <p>I've googled and searched SO for "js-bson: Failed to load c++ bson extension, using pure JS version" and tried everything except answers that didn't work for others or answers that were centered around issues with mongoose as I'm not using mongoose in this exercise.</p>
  
  <p>Some of the things I've tried so far:</p>
  
  <pre><code>sudo apt-get install gcc make build-essential
  rm -rf node_modules
  npm cache clean
  npm install
  </code></pre>
  
  <p>(but this exercise doesn't even use a package.json file)</p>
  
  <hr>
  
  <p>I tried re-installing node-mongodb with the most recent version</p>
  
  <hr>
  
  <p>I tried</p>
  
  <pre><code>npm install -g node-gyp
  </code></pre>
  
  <hr>
  
  <p>and I tried an answer at SO here <a href="https://stackoverflow.com/questions/21656420/failed-to-load-c-bson-extension">Failed to load c++ bson extension</a> :</p>
  
  <p>going into node_modules/mongodb/node_modules/bson directory and from there use</p>
  
  <pre><code>node-gyp rebuild
  </code></pre>
  
  <p>and that produced: </p>
  
  <pre><code>gyp info it worked if it ends with ok
  gyp info using node-gyp@0.13.1
  gyp info using node@0.11.9-pre | linux | x64
  gyp ERR! configure error 
  gyp ERR! stack Error: "pre" versions of node cannot be installed, use the --nodedir flag     instead
  gyp ERR! stack     at install (/usr/local/lib/node_modules/node-    gyp/lib/install.js:66:16)
  gyp ERR! stack     at Object.self.commands.(anonymous function) [as install]     (/usr/local/lib/node_modules/node-gyp/lib/node-gyp.js:66:37)
  gyp ERR! stack     at getNodeDir (/usr/local/lib/node_modules/node-    gyp/lib/configure.js:152:20)
  gyp ERR! stack     at /usr/local/lib/node_modules/node-gyp/lib/configure.js:95:9
  gyp ERR! stack     at ChildProcess.exithandler (child_process.js:659:7)
  gyp ERR! stack     at ChildProcess.EventEmitter.emit (events.js:106:17)
  gyp ERR! stack     at maybeClose (child_process.js:773:16)
  gyp ERR! stack     at Socket.&lt;anonymous&gt; (child_process.js:986:11)
  gyp ERR! stack     at Socket.EventEmitter.emit (events.js:103:17)
  gyp ERR! stack     at Pipe.close (net.js:458:12)
  gyp ERR! System Linux 3.13.0-29-generic
  gyp ERR! command "node" "/usr/local/bin/node-gyp" "rebuild"
  gyp ERR! cwd /home/nathaniel/node_modules/mongodb/node_modules/bson
  gyp ERR! node -v v0.11.9-pre
  gyp ERR! node-gyp -v v0.13.1
  gyp ERR! not ok 
  </code></pre>
  
  <hr>
  
  <p>I saw a SO answer here <a href="https://stackoverflow.com/questions/23190106/failed-to-load-c-bson-extension-using-pure-js-version">Failed to load c++ bson extension, using pure JS version</a>  saying:</p>
  
  <p>"Sounds like you didn't have gcc/g++/make/python 2.x installed when you used npm to install the bson module. Try installing them first and then use npm to reinstall bson."</p>
  
  <p>But this answer wasn't selected as a solve and I have no idea what this means as I'm a serious noob.</p>
  
  <hr>
  
  <p>I really want to continue learning mongodb but I don't want some package bug to cause problems down the road and make me mistakenly think I'm doing something wrong.  I would really like to get this cleared up now. </p>
  
  <p>I also noticed that many of the other people posting this issue (without mongoose or express involvement) have not selected an answer or replied that they fixed the issue.</p>
  
  <p>I'm running Ubuntu 14.04 LTS and node v0.11.9-pre</p>
  
  <p>Any help will be greatly appreciated!!!!</p>