Registry / database / maxmind-city

maxmind-city

JSON →
library1.0.3-20191224jsnpmunverified

Pre-packaged MaxMind GeoLite2 City database for node-maxmind (v1.0.3-20191224). Provides IP-to-city geolocation data including continent, country, and approximate latitude/longitude. Updated weekly. Designed for use with the `maxmind` npm package; this package only contains the database binary, not the lookup engine. Requires manual license key registration with MaxMind due to December 2019 license changes. Note: latitude/longitude are approximate and should not be used for precise location.

npm install maxmind-city
INSTALL
IMPORT
SIG · MAXMIND-CITY
M
maxmind-city
databasejavascriptv1.0.3-20191224
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.

maxmind-city
const maxmind = require('maxmind'); require('maxmind-city')
require('maxmind-city') without loading maxmind first
This package exports the database file path, not a lookup API. Use with maxmind.openSync() or maxmind.open()
maxmind
const maxmind = require('maxmind')
import { openSync } from 'maxmind' (wrong default export)
maxmind is a CommonJS module; no ES module export available
lookupCity.get(ip)
const lookup = maxmind.openSync(require('maxmind-city')); const result = lookup.get('8.8.8.8')
require('maxmind-city').get() (database is not an object with methods)
Database file must be opened via maxmind.openSync() or maxmind.open()

Shows loading the maxmind package, opening the GeoLite2 City database, and performing an IP lookup.

const maxmind = require('maxmind'); const lookup = maxmind.openSync(require('maxmind-city')); const ip = process.env.IP || '8.8.8.8'; const city = lookup.get(ip); if (city) { console.log('City result:', JSON.stringify(city, null, 2)); } else { console.log('Not found'); }
Debug
Known issues
breakingMaxMind changed GeoLite2 license terms effective December 30, 2019. Old database files may not be compatible; you need to register for a free license key and download updated databases.
fix
Sign up at https://www.maxmind.com/en/geolite2/signup and use a newer package version or manually download the database.
affects: >=1.0.0
gotchaThe maxmind-city package only contains the database file, not the lookup logic. You must install maxmind separately.
fix
npm install maxmind maxmind-city
affects: all
gotchaThe node-maxmind package (used as peer dependency) has breaking changes across major versions. v3+ uses ESM and changed its API (e.g., .open() returns a Promise, not synchronous).
fix
If using maxmind v3+, use async/await: const lookup = await maxmind.open(require('maxmind-city'));
affects: >=1.0.0
deprecatedThe maxmind-city package has not been updated on npm since 2019-12-24. Future changes may be needed for compatibility with newer node-maxmind.
fix
Consider manual database downloads from MaxMind and use maxmind.openBuffer() to load custom files.
affects: >=1.0.0
gotchaLatitude and longitude in city data are approximate (accuracy_radius field). They should not be used to identify street addresses or households.
fix
Always check accuracy_radius field and use latitude/longitude only for regional analysis, not precise geolocation.
affects: all
Errors
Common errors & fixes
Error: Cannot find module 'maxmind'
Missing required peer dependency 'maxmind'.
fix
npm install maxmind
TypeError: maxmind.openSync is not a function
Using an older version of 'maxmind' (v2.x) that uses .openSync() but actually .openSync() did not exist; or using v3+ where .open() is async.
fix
For maxmind v2: use maxmind.open() synchronous; for v3+: use async/await with maxmind.open().
Error: invalid database file: /path/to/node_modules/maxmind-city/index.js
Passing the require result directly to maxmind.openSync() incorrectly; the database path is not exported as a binary.
fix
Use require('maxmind-city') directly as argument; it returns the path to the .mmdb file.
Upgrade
Version history
1.0.3-20191224latest on npm
Audit
Dependencies
maxmindrequiredRequired to open and query the city database
Agent activity
4 hits · last 30 days
node
4
Resources