Install & Compatibility
Where this runs
No compatibility data collected yet for this library.
Code
Verified usage
Verified import paths — ran on the pinned version, not inferred.
covertToMYSQL
✓ import { covertToMYSQL } from 'excel-to-mysql'
✗ const excelMysql = require('excel-to-mysql'); excelMysql.covertToMYSQL(...)
ESM and CJS both work but the main function has a typo in its name (covert not convert).
convertToFile
✓ import { convertToFile } from 'excel-to-mysql'
✗ const { convertToFile } = require('excel-to-mysql');
Correct name for SQL file generation. Note that the sibling function 'covertToMYSQL' is misspelled.
excelMysql
✓ const excelMysql = require('excel-to-mysql');
✗ import excelMysql from 'excel-to-mysql';
Default import is not supported in ESM; this package only provides named exports. Use CJS require or named import.
Shows basic usage: import the module, set up credentials (with environment variables for security), and call covertToMYSQL to insert Excel data into a MySQL table.
const { covertToMYSQL } = require('excel-to-mysql');
const credentials = {
host: process.env.DB_HOST ?? 'localhost',
port: 3306,
user: process.env.DB_USER ?? 'root',
pass: process.env.DB_PASS ?? '',
path: './data.xlsx',
table: 'my_table',
db: 'test_db',
endConnection: true,
};
const options = { verbose: true, autoId: false };
covertToMYSQL(credentials, options, (err, result) => {
if (err) console.error(err);
else console.log('Data imported successfully');
});
Debug
Known issues
gotchaThe main function name is misspelled as 'covertToMYSQL' (missing 'n' in 'convert'). This is intentional and will not be fixed. Using 'convertToMYSQL' will cause a ReferenceError.fixAlways use the exact function name 'covertToMYSQL' when calling.
affects: all
deprecatedThe repository has no recent updates and may not support newer Node.js versions or MySQL 8+ authentication plugins. The last commit was years ago.fixConsider using more actively maintained alternatives like 'xlsx-to-mysql' or writing custom code with 'xlsx' and 'mysql2'.
affects: all
gotchaSetting endConnection to false may prevent the Node process from exiting. The documentation warns: 'endConnection false may not terminate the process.'fixAlways set endConnection: true unless you have a specific reason to keep the connection open and manage it externally.
affects: all
breakingIn version 2.x, the function signatures changed. The callback is now the third argument, and options were restructured. Old code passing callback as second argument will break.fixUpdate calls to use (credentials, options, callback) signature. Check the changelog for exact migration.
affects: <2.0.0 || >=2.0.0
Errors
Common errors & fixes
ReferenceError: convertToMYSQL is not defined
Using the correctly spelled function name 'convertToMYSQL' which does not exist.
fixUse the exact function name 'covertToMYSQL' (with 'o' instead of 'n' after 'c').
Error: ER_NOT_SUPPORTED_AUTH_MODE: Client does not support authentication protocol requested by server
MySQL 8+ uses caching_sha2_password by default, which may not be compatible with the older 'mysql' package used by this module.
fixALTER USER 'user'@'host' IDENTIFIED WITH mysql_native_password BY 'password'; Or switch to 'mysql2' package and adjust the module's connection.
TypeError: Cannot read property 'forEach' of undefined
Excel file path is incorrect or file is empty. The module expects a valid file with at least one row of data.
fixDouble-check the file path and ensure the spreadsheet is not empty and has headers in the first row.
Audit
Dependencies
mysqlrequiredPeer dependency — required for MySQL connections and queries