user690936 user690936 - 1 year ago 77
MySQL Question

Canno't find module mysql - error

i have installed nodejs and mysql(also the work bench)

i am building a server using nodejs and mysql.

in my code i write:

var mysql = require('mysql');
var TEST_DATABASE = 'nodejs_mysql_test';
var TEST_TABLE = 'test';
var client = mysql.createClient({
user: 'root',
password: 'root',

client.query('CREATE DATABASE '+TEST_DATABASE, function(err) {
if (err && err.number != mysql.ERROR_DB_CREATE_EXISTS) {
throw err;

and the compiler gives me an error:
Error: cannot find module 'mysql'

any ideas?

thank you

Answer Source

i think that i solved it.

there is a folder node_modules under the nodejs folder in that folder there is a mysql folder. copied it to the folder that from there i am running my program, and i t works:)

Recommended from our users: Dynamic Network Monitoring from WhatsUp Gold from IPSwitch. Free Download