Registry / serialization / parse-address

parse-address

JSON →
library0.1.0jsnpmunverified

This package, `parse-address`, currently at version 1.1.2, provides a JavaScript port of the Perl Geo::StreetAddress::US module for parsing US street addresses. It is designed to be highly forgiving and robust, using a regex-based approach to extract components like street number, prefix, street name, type, city, state, and ZIP code from various user-provided address strings. Key features include handling directional prefixes and suffixes, fractional building numbers, building units, grid-based addresses, and both 5 and 9-digit ZIP codes, along with all official USPS abbreviations for street types and state names. The package's release cadence appears to be infrequent, with the last significant version jump (1.0.0) occurring after a long period. Its core differentiator is its direct port from a proven Perl library, emphasizing fault tolerance in parsing diverse address formats prevalent in the United States.

npm install parse-address
INSTALL
IMPORT
SIG · PARSE-ADDRESS
P
parse-address
serializationjavascriptv0.1.0
Install
Import
Disk
Pass rate
0/ 6
Env Coverage0 / 6
glibc
1822
musl
1822
Install & Compatibility
Where this runs
tested against v? · npm install
Install × environment matrix
Each cell = how many times install + import succeeded across repeated harness runs. Partial = flaky.
glibc = Debian/Ubuntu slim · musl = Alpine Linux
musl
node 18226 runs
build_error
glibc
node 18226 runs
build_error
Code
Verified usage

Verified import paths — ran on the pinned version, not inferred.

parser
const parser = require('parse-address');
import parser from 'parse-address';
The library is primarily a CommonJS module. The `require` call returns the main parser object.
parseLocation
const { parseLocation } = require('parse-address'); // If using object destructuring, requires the 'parser' object to be assigned first, then destructure if module.exports is an object with named keys. // More robust: const parser = require('parse-address'); const parsed = parser.parseLocation(...);
import { parseLocation } from 'parse-address';
Direct named ESM imports will fail as the package does not provide explicit named exports for ESM consumers. The `parseLocation` method is accessed via the default exported parser object.
parseAddress (browser global)
<script type="text/javascript" src="./node_modules/parse-address/parse-address.min.js"></script> <script> var parsed = parseAddress.parseLocation('1005 N Gravenstein Highway Sebastopol CA 95472'); </script>
When included directly in the browser via a script tag, the library exposes a global `parseAddress` object.

Demonstrates how to import the parser and use `parseLocation` to extract components from US street addresses, including common and informal formats.

const parser = require('parse-address'); const addressString = '1005 N Gravenstein Highway Sebastopol CA 95472'; const parsedAddress = parser.parseLocation(addressString); console.log('Original Address:', addressString); console.log('Parsed Address:', parsedAddress); // Example of another address type const intersectionString = 'Main St & First Ave, Anytown CA'; const parsedIntersection = parser.parseLocation(intersectionString); console.log('Parsed Intersection:', parsedIntersection); // Demonstrating robustness with a less formal address const informalAddress = '456 w Elm apt 3B, New York, NY 10001'; const parsedInformal = parser.parseLocation(informalAddress); console.log('Parsed Informal Address:', parsedInformal);
Debug
Known issues
breakingThe `parse-address` package is a CommonJS (CJS) module and does not provide an official ES Module (ESM) entry point. Attempting to use `import ... from 'parse-address'` in an ESM context or a bundler configured for ESM may lead to import errors or unexpected behavior.
fix
Use `const parser = require('parse-address');` for Node.js environments. For browser usage, include `parse-address.min.js` directly via a script tag.
affects: >=0.0.1
gotchaThis package does not ship with official TypeScript type definitions. Developers using TypeScript will need to create their own declaration files (`.d.ts`) or rely on community-provided types if available (e.g., `@types/parse-address`).
fix
Consider creating a `parse-address.d.ts` file in your project with `declare module 'parse-address' { ... }` or check for `@types/parse-address` on npm.
affects: >=0.0.1
gotchaThe transition to v1.0.0 implemented a 'normalizer' feature, which, while intended to improve parsing, might subtly alter the output structure or parsed values for certain edge cases compared to pre-1.0.0 versions. Always test thoroughly when upgrading.
fix
Review parsing results for a representative set of addresses after upgrading to v1.x to ensure consistency with expected output.
affects: >=1.0.0
Errors
Common errors & fixes
TypeError: parse_address__WEBPACK_IMPORTED_MODULE_0__ is not a function (or similar 'is not a function' error)
This error typically occurs when a bundler (like Webpack or Rollup) tries to interpret a CommonJS `module.exports = { ... }` as an ESM `default` export, and then an incorrect named import is used, or the default export is not handled correctly.
fix
Ensure you are using `const parser = require('parse-address');` in your JavaScript/TypeScript files, especially in Node.js or when configuring bundlers to correctly handle CommonJS modules. If using `import`, try `import * as parser from 'parse-address';` (though this might still have issues depending on bundler config).
SyntaxError: Named export 'parseLocation' not found. The requested module 'parse-address' does not provide an export named 'parseLocation'
Attempting to use a named ESM import (`import { parseLocation } from 'parse-address';`) for a package that only provides a CommonJS default export (an object containing `parseLocation`).
fix
Use the CommonJS `require` syntax: `const parser = require('parse-address');` and then access `parser.parseLocation(...)`.
Upgrade
Version history
0.1.0latest on npm
Audit
Dependencies

No dependency data recorded yet.

Agent activity
2 hits · last 30 days
node
2
Resources
parse-address — npm install parse-address · libregistry