Mysql module not found

We have installed the mysql module using npm install mysql and restarted the cwmp service. Our ext script is not able to run the module.

Channel has faulted; channel=“boot” retries=0 faultCode=“ext.Error” faultMessage=“Cannot find module ‘mysql’\nRequire stack:\n- /opt/genieacs/ext/cpe-config.js\n- /usr/lib/node_modules/genieacs/bin/genieacs-ext”

var mysql = require('mysql');

var con = mysql.createConnection({
    host: "host",
    user: "user",
    password: "password",
    database: "database"
});

function DB(args, callback) {
    let mac = args[0];

    con.connect(function(err) {
      if (err) throw err;
      con.query('SELECT * FROM acs WHERE mac = ' + mysql.escape(mac), function (err, result, fields) {
        if (err) throw err;
	  console.log(result[0]); 
	  return callback(null, results[0]);
      });
    });
}

exports.DB = DB;

Finally figured out that I needed to do the npm install mysql in the ext directory. It didnt want to work while the module was only in the genieacs module directory.

2 Likes

Thanks! same issue, saw your post and saved me a bunch of time.