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.
checkCode
✓ import { checkCode } from 'hihtml'
✗ import hihtml from 'hihtml'
hihtml exports named functions, not a default export. Available in ESM only (no CommonJS).
checkLinks
✓ import { checkLinks } from 'hihtml'
✗ const { checkLinks } = require('hihtml')
Package is ESM-only. Requires Node >= 16 and "type":"module" in package.json or .mjs extension.
minify
✓ import { minify } from 'hihtml'
✗ import { minify as minimize } from 'hihtml'
Function name is `minify`, not `minimize` or `minifier`.
collect
✓ import { collect } from 'hihtml'
collect() returns an array of file paths. Required as input for other functions.
minifyString
✓ import { minifyString } from 'hihtml'
String variant that accepts HTML as a string (no file I/O).
Programmatic usage: validate HTML, check links, minify, and enforce conformance gate with string variants.
import { collect, checkCode, checkLinks, minify, minifyString } from 'hihtml';
// Validate and check for deprecated markup
const files = await collect('./src');
const validationResult = await checkCode(files);
console.log('Errors:', validationResult.validation.countErrors);
console.log('Deprecated:', validationResult.deprecation.countIssues);
// Check links
const linkResult = await checkLinks(files);
console.log('Broken links:', linkResult.countBroken);
// Minify in-place
const minifyResult = await minify(files, files);
console.log('Saved bytes:', minifyResult.saved);
// Minify a string directly
const minified = await minifyString('<p>Hello world</p>');
console.log('Minified:', minified);
// Use with --all equivalent logic
const { validation } = await checkCode(files);
if (validation.countErrors === 0) {
await minify(files, files);
}
Errors
Common errors & fixes
SyntaxError: The requested module 'hihtml' does not provide an export named 'default'
Trying to import default export but package only provides named exports.
fixUse named imports: import { checkCode } from 'hihtml'; ERR_REQUIRE_ESM: require() of ES Module /node_modules/hihtml/index.js not supported.
Using require() on an ESM-only package.
fixSwitch to import syntax or use dynamic import(): const hihtml = await import('hihtml'); TypeError: checkCode is not a function
Forgetting to await the asynchronous function or destructuring incorrectly.
fixEnsure you await the result: const result = await checkCode(files);
Audit
Dependencies
html-validaterequiredHTML validation engine
obsohtmlrequiredDeprecated markup detection
html-minifier-nextrequiredHTML minification