user2663856 user2663856 - 1 year ago 349
MySQL Question

How to install node mysql module in nw.js?

I am building a desktop application in NW.JS. Now, I want to store data in database using MySQL but I don't know how to add MySQL node module in my nw.js application. Kindly answer it in detail i am beginner. I added

but it says
no mysql module exist

var sql = require('mysql');
var connection = mysql.createConnection({
host : 'locahost',
user : 'root',
password : '',
database : 'db_delvin'

Answer Source

On the command line (terminal) run the following command in the root folder of your project:

npm install mysql --save

the --save appendix will save the dependency in the package.json of your application

Every time you see a require or import in Javascript it means that a module is necessary to be loaded to charge dependency's functionalities. NW.js is a module loader for the DOM but it still requires the modules you want to use in your application to be installed.

Check the package.json in the root of your application folder to see other required dependencies.

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