In my Node.js application, I am trying to connect to a MySQL database hosted on Amazon.
$ npm install mysql
My code looks something like this:
var mysql = require('mysql'); var connection = mysql.createConnection({ host : 'my amazon sql db', user : 'me', password : 'secret', database : 'my_db' }); connection.connect(); connection.query('SELECT 1 + 1 AS solution', function(err, rows, fields) { if (err) throw err; console.log('The solution is: ', rows[0].solution); }); connection.end();
I can connect to my MySQL database using Workbench, so I'm sure my credentials are ok.
When I try to connect, I get the following error:
Connection.js: 91 Uncaught TypeError: Net.createConnection is not a function
Debugging code from the npm library - this is where the error occurs in connection.js :
this._socket = (this.config.socketPath) ? Net.createConnection(this.config.socketPath) : Net.createConnection(this.config.port, this.config.host);
connection.js has a dependency:
var Net = require('net');
I am running Node.js locally on my windows machine.
Can someone tell me what might cause this error?
Separate ticket created: Error calling Node.js net.createConnection