Provides a comprehensive, typed mapping of MySQL server error codes to their symbolic names (e.g., ER_DUP_ENTRY) for Node.js and TypeScript projects. Current version 0.1.3 is stable but rarely updated; includes all standard MySQL error codes up to MySQL 8.0. Ships with TypeScript definitions, supports both ESM and CommonJS imports, and is dependency-free. Useful for handling MySQL errors without magic numbers.
npm install mysql-error-codesNo compatibility data collected yet for this library.
Verified import paths — ran on the pinned version, not inferred.
Shows how to import and use MysqlErrorCodes to check for duplicate entry error (ER_DUP_ENTRY) after an INSERT failure.
Use destructured require or named import: const { MysqlErrorCodes } = require('mysql-error-codes');Check the MySQL error reference for any missing codes and contribute to the package, or use an alternative like 'mysql-error-codes' from another source.
Always import from 'mysql-error-codes' without specifying a file extension.
Ensure you use const { MysqlErrorCodes } = require('mysql-error-codes'); (with parentheses).Run npm install --save mysql-error-codes and verify the package is in node_modules.
No dependency data recorded yet.