title: node refuses to find mysql from script
body: <p>I want to achieve that node prints me a table from MySql on my Windows 7 (64bit) machine but fail. Sorry for the long post in advance, I tried to be complete, also I failed to find this error in the forum. The optimistic mysql.js file I typed in Notepad++ was </p>
  
  <pre><code>var mysql = require('node-mysql');
  var connectParams = {'hostname' : 'localhost','user' : 'dev','password': 'dev','database' : 'upandrunning'};
  var db = new mysql.Database(connectParams);
  db.connect( function(err)   {
      if(err) return console.log('Failed to connect ' + err);
  
      this.query()
      .select(['id', 'user_login'])
      .from('users')
      .execute(
          function(err, rows, columns){
              if(err) return console.log('err on query '  + err);
  
              console.log(rows);
          })});
  </code></pre>
  
  <p>Node keeps returning</p>
  
  <pre><code>C:\dev\nodejs\0.10\tutorials\node-up-and-running&gt;node tutorials\node-up-and-running\mysql.js
  
  module.js:340
  throw err;
        ^
  Error: Cannot find module 'C:\dev\nodejs\0.10\tutorials\node-up-and-running\tutorials\node-up-and-running\mysql.js'
  at Function.Module._resolveFilename (module.js:338:15)
  at Function.Module._load (module.js:280:25)
  at Function.Module.runMain (module.js:497:10)
  at startup (node.js:119:16)
  at node.js:902:3
  </code></pre>
  
  <p>Why??</p>
  
  <p>Before the node command I told Squirrel to do</p>
  
  <pre><code>drop database if exists upandrunning;
  create database upandrunning;
  grant all privileges on upandrunning.* to 'dev'@'%' identified by 'dev';
  use upandrunning;
  create table users(
  id int auto_increment primary key,
  user_login varchar(25),
  user_nicename varchar(75)
  );
  </code></pre>
  
  <p>using my localhost root account (bad), but all seemed fine because squirrel object tab showed new upandrunning db.
  Node.exe is on C:\dev\nodejs\0.10\ but from dos prompt:</p>
  
  <pre><code>C:\dev\nodejs\0.10\tutorials\node-up-and-running&gt;node -v
  </code></pre>
  
  <p>gives</p>
  
  <pre><code>v0.10.26
  </code></pre>
  
  <p>My file mysql.js has been reduced to the mere</p>
  
  <pre><code>var mysql = require('node-mysql');
  </code></pre>
  
  <p>where the error must be. I ran the following commands from C:\dev\nodejs\0.10\tutorials\node-up-and-running></p>
  
  <pre><code>npm install -g mysql
  npm install -g node-mysql
  npm install -g db-mysql
  </code></pre>
  
  <p>These were the ones i could find.
   After each install the same error above. </p>
  
  <p>Any suggestions please how to make node cooperate?</p>
  
  <p>I admit I lack node trouble shooting skills, but studying module.js, should not be necessary. 
  Also, do you know of, and enjoy working in, a free and easy to work with code completion ide for node? 
  And is there some way to debug other than console.log() ?. 
  Lastly what are your ideas on layout conventions for reducing the closing brackets because they hurt the eyes.</p>
  
  <p>The site suggested From <a href="https://stackoverflow.com/questions/15636367/nodejs-require-a-global-module-package">NodeJS require a global module/package</a> 
  but how do i get the node_path variable on dos prompt and how to set it:
  C:\dev\nodejs\0.10\tutorials\node-up-and-running>set NODE_PATH</p>
  
  <pre><code>Environment variable NODE_PATH not defined
  </code></pre>
  
  <p>Ok set NODE_PATH=c:\dev\nodejs\0.10
  C:\dev\nodejs\0.10\tutorials\node-up-and-running>node tutorials\node-up-and-running\mysql.js</p>
  
  <pre><code> 'node' is not recognized as an internal or external command, operable program or batch file.
  </code></pre>
  
  <p>Closing and reopening dos makes this go away.</p>
  
  <p>C:\dev\nodejs\0.10>set NODE_PATH=%NODE_PATH%;C:\dev\nodejs\0.10\node_modules</p>
  
  <p>And it works.. But now it fails on </p>
  
  <pre><code>var mysql = require('mysql');
  var connectParams = {'hostname' : 'localhost','user' : 'dev','password': 'dev','database' : 'upandrunning'};
  var db = new mysql.Database(connectParams);
  
  C:\dev\nodejs\0.10\mysql.js:3
  var db = new mysql.Database(connectParams);
           ^
  TypeError: undefined is not a function
  at Object.&lt;anonymous&gt; (C:\dev\nodejs\0.10\mysql.js:3:10)
  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 Function.Module.runMain (module.js:497:10)
  at startup (node.js:119:16)
  at node.js:902:3
  </code></pre>
  
  <p>and if i remove the new it says </p>
  
  <p>C:\dev\nodejs\0.10\mysql.js:3
  var db =  mysql.Database(connectParams);
                  ^
      TypeError: Object # has no method 'Database'
      at Object. (C:\dev\nodejs\0.10\mysql.js:3:17)</p>
  
  <p>Using the REPL:</p>
  
  <blockquote>
    <p>var mysql = require('mysql');
    undefined
    var connectParams = {'hostname' : 'localhost','user' : 'dev','password': 'dev'
    ,'database' : 'upandrunning'};
    undefined
    var db = new mysql.Database(connectParams);
    TypeError: undefined is not a function
        at repl:1:10
        at REPLServer.self.eval (repl.js:110:21)
        at repl.js:249:20
        at REPLServer.self.eval (repl.js:122:7)
        at Interface. (repl.js:239:12)
        at Interface.EventEmitter.emit (events.js:95:17)
        at Interface._onLine (readline.js:202:10)
        at Interface._line (readline.js:531:8)
        at Interface._ttyWrite (readline.js:760:14)
        at ReadStream.onkeypress (readline.js:99:10)</p>
  </blockquote>