Registry / http-networking / problem-details-http

problem-details-http

JSON →
library2.0.0jsnpmunverified

Library for HTTP problem details (RFC 7807) error responses. Current stable version is 2.0.0, updated frequently via GitHub. Supports building and sending consistent error payloads with optional extension members. Differentiator: fluent builder pattern, defaults for status codes and titles, TypeScript types included, zero dependencies.

npm install problem-details-http
INSTALL
IMPORT
SIG · PROBLEM-DETAILS-HT
P
problem-details-http
http-networkingjavascriptv2.0.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.

PDBuilder
import { PDBuilder } from 'problem-details-http'
const PDBuilder = require('problem-details-http')
ESM-only package; CommonJS not supported.
default
import problemDetailsHttp from 'problem-details-http'
Default import not documented; prefer named import { PDBuilder }.
ProblemDetail
import type { ProblemDetail } from 'problem-details-http'
TypeScript type export for type-checking problem detail objects.

Creates a problem details object using the builder pattern with default or custom values.

import { PDBuilder } from 'problem-details-http'; const pd = PDBuilder.fromDetail('Resource not found') .type('https://example.com/errors/not-found') .title('Not Found') .status(404) .instance('/api/users/123') .build(); console.log(pd); // { // type: 'https://example.com/errors/not-found', // status: 404, // title: 'Not Found', // detail: 'Resource not found', // instance: '/api/users/123' // }
Debug
Known issues
breakingv2.0: Default import removed; must use named import { PDBuilder }.
fix
Change `import problemDetailsHttp from 'problem-details-http'` to `import { PDBuilder } from 'problem-details-http'`.
affects: >=2.0.0
gotchaPDBuilder.fromDetail() is the only entry point; PDBuilder constructor is private.
fix
Always start with `PDBuilder.fromDetail('...')`.
affects: *
deprecatedThe `setStatus` method was renamed to `status` in v1.5, but old name still works.
fix
Use `.status()` instead of `.setStatus()`.
affects: >=1.5.0 <2.0.0
Errors
Common errors & fixes
Cannot find module 'problem-details-http' or its corresponding type declarations.
Package installed as devDependency or not installed; or missing types.
fix
Run `npm install problem-details-http` (not --save-dev). Add `"types": "dist/index.d.ts"` to tsconfig.json if needed.
TypeError: PDBuilder.fromDetail is not a function
Using CommonJS require with ESM-only package.
fix
Use `import { PDBuilder } from 'problem-details-http'` or enable ES modules in project.
Property 'setStatus' does not exist on type 'PDBuilder'.
Upgraded from v1.x to v2.x where `setStatus` was removed.
fix
Replace `.setStatus()` with `.status()`.
Upgrade
Version history
2.0.0latest on npm
Audit
Dependencies

No dependency data recorded yet.

Agent activity
8 hits · last 30 days
node
8
Resources
problem-details-http — npm install problem-details-http · libregistry