Registry / database / mysql-error-keys

mysql-error-keys

JSON →
library0.1.3jsnpmunverified

A curated list of constants for MySQL error key strings (e.g., 'ER_DUP_ENTRY'). Current stable version 0.1.3, with infrequent releases. Provides both named exports and a default object with all keys for use in Node.js and browser environments. Differentiates from raw error code maps by offering TypeScript type definitions and a simple constant-based approach to avoid magic strings in error handling.

npm install mysql-error-keys
INSTALL
IMPORT
SIG · MYSQL-ERROR-KEYS
M
mysql-error-keys
databasejavascriptv0.1.3
harness data pending
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.

mek
import { mek } from 'mysql-error-keys'
const mek = require('mysql-error-keys').mek
Default export is not an object; use named import for the mek object.
ER_DUP_ENTRY
import { ER_DUP_ENTRY } from 'mysql-error-keys'
import { ER_DUP_ENTRY as something } from 'mysql-error-keys'
Named exports match MySQL error key strings exactly.
require
const { ER_DUP_ENTRY } = require('mysql-error-keys')
const mek = require('mysql-error-keys').default
CommonJS users can destructure or use the default export directly.

Shows how to import the mek object and use a constant for error comparison, avoiding raw strings.

import { mek } from 'mysql-error-keys'; try { // some operation that might cause a MySQL duplicate entry } catch (err: any) { if (err.code === mek.ER_DUP_ENTRY) { console.log('Duplicate entry, handle accordingly.'); } }
Debug
Known issues
gotchaThe package version is 0.1.x, API may change without major version bump.
fix
Pin dependency to exact version or monitor updates.
affects: <1.0.0
deprecatedSome MySQL error keys may be outdated if MySQL releases new errors; the package may not be updated promptly.
fix
Verify keys against official MySQL documentation; contribute updates.
affects: *
gotchaImporting { mek } is the recommended way, but some users mistakenly try import * as mek from 'mysql-error-keys' which fails.
fix
Use import { mek } from 'mysql-error-keys' instead of namespace import.
affects: *
Errors
Common errors & fixes
TypeError: Cannot read properties of undefined (reading 'ER_DUP_ENTRY')
Used default import without the mek wrapper.
fix
Use import { mek } from 'mysql-error-keys' and then mek.ER_DUP_ENTRY.
SyntaxError: The requested module 'mysql-error-keys' does not provide an export named 'default'
Tried import mek from 'mysql-error-keys' which expects a default export that doesn't exist.
fix
Use import { mek } from 'mysql-error-keys' instead.
Module not found: Error: Can't resolve 'mysql-error-keys'
Package not installed or incorrectly imported in a browser bundler without proper configuration.
fix
Install package with npm install mysql-error-keys and ensure bundler can resolve Node modules.
Upgrade
Version history
0.1.3latest on npm
Audit
Dependencies

No dependency data recorded yet.

Agent activity
2 hits · last 30 days
node
2
Resources
mysql-error-keys — npm install mysql-error-keys · libregistry