Hi friend, I try node.js, which is in demand on time today, so I thought to get some hands on this amazing js,
so, first, I want to install mysql to create a database for my application,
I used the following command to install mysql
$ npm install mysql
sql1.js code
var mysql = require('mysql');
var connection = mysql.createConnection({
host : 'localhost',
user : 'me',
password : 'secret'
});
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();
but when I launched my sql1.js which contains sql code it
gives an error
pitambar@pitambar-TravelMate-4740:~/node-example/hands-on-node.js$
node sql1.js
node.js:134
throw e; // process.nextTick error, or 'error' event on first tick
^ TypeError: Object prototype may only be an Object or null
at Function.create (native)
at Object.inherits (util.js:425:27)
at Object.<anonymous> (/home/pitambar/.node_libraries/.npm/readable-stream/1.1.10/package/lib/_stream_readable.js:55:6)
at Module._compile (module.js:402:26)
at Object..js (module.js:408:10)
at Module.load (module.js:334:31)
at Function._load (module.js:293:12)
at require (module.js:346:19)
at Object.<anonymous> (/home/pitambar/.node_libraries/.npm/readable-stream/1.1.10/package/readable.js:1:90)
at Module._compile (module.js:402:26) pitambar@pitambar-TravelMate-4740:~/node-example/hands-on-node.js$
what to do in that case, i'm new to node
any help would be appreciated, thanks
source
share