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.
* as xkmobCommon
✓ import * as xkmobCommon from 'xkmob-common'
✗ const xkmobCommon = require('xkmob-common')
Package ships TypeScript types; ESM import is preferred. CommonJS require may still work but types may not be inferred.
default export
✓ import xkmobCommon from 'xkmob-common'
If the package has a default export, this works. Otherwise use namespace import.
specific named exports (e.g., connectMysql, connectRedis)
✓ import { connectMysql, connectRedis } from 'xkmob-common'
✗ import { connectMysql } from 'xkmob-common/src/connectMysql'
Named exports likely available but not explicitly documented. Avoid deep imports as they may break.
TypeScript types
✓ import type { Config } from 'xkmob-common'
Use import type for type-only imports to avoid bundling runtime code.
Initializes config, MySQL connection, and Redis connection using environment variables. Demonstrates basic usage of the library's three main capabilities.
import * as xkmobCommon from 'xkmob-common';
// Initialize config (example)
const config = xkmobCommon.getConfig({ path: './config.json' });
// Connect to MySQL (example)
const mysqlConn = xkmobCommon.connectMysql({
host: process.env.MYSQL_HOST ?? 'localhost',
user: process.env.MYSQL_USER ?? 'root',
password: process.env.MYSQL_PASSWORD ?? '',
database: process.env.MYSQL_DATABASE ?? 'test'
});
// Connect to Redis (example)
const redisClient = xkmobCommon.connectRedis({
host: process.env.REDIS_HOST ?? 'localhost',
port: process.env.REDIS_PORT ? Number(process.env.REDIS_PORT) : 6379
});
// Example: set and get from redis
await redisClient.set('key', 'value');
const value = await redisClient.get('key');
console.log('Redis value:', value);
Errors
Common errors & fixes
Cannot find module 'xkmob-common'
Package not installed or not in node_modules.
fixRun: npm install xkmob-common
TypeError: xkmobCommon.connectMysql is not a function
The function may not exist or named differently.
fixCheck package exports: import * as xkmobCommon from 'xkmob-common'; console.log(Object.keys(xkmobCommon));
Module not found: Can't resolve 'xkmob-helper'
peer dependency xkmob-helper not installed.
fixInstall xkmob-helper: npm install xkmob-helper
Audit
Dependencies
xkmob-helperrequiredCore companion package providing additional helper utilities; likely required for full functionality.
mysqloptionalMySQL database driver assumed for database operations.
redisoptionalRedis client assumed for caching operations.