Registry / serialization / simple-mime

simple-mime

JSON →
library0.1.0jsnpmunverified

A minimal mime type lookup library for Node.js, providing a simple function to map file extensions to MIME types. Version 0.1.0 is the current stable release. It focuses on being lightweight and dependency-free, unlike the more feature-rich `mime` package. Ideal for small static file servers where minimalism is preferred.

npm install simple-mime
INSTALL
IMPORT
SIG · SIMPLE-MIME
S
simple-mime
serializationjavascriptv0.1.0
Install
—
Import
—
Disk
—
Pass rate
0/ 6
Env Coverage0 / 6
glibc
18–22
musl
18–22
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 18–226 runs
build_error
glibc
node 18–226 runs
build_error
Code
Verified usage

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

default
✓ var getMimeType = require('simple-mime')('application/octet-stream')
✗ const mime = require('simple-mime')
The module exports a function that takes a fallback MIME type and returns a lookup function. Common mistake is to require the module without calling it.
lookup function
✓ var type = getMimeType('file.mp3')
✗ var type = getMimeType['mp3']
The returned function expects a filename or extension string. Do not treat it as an object with extension keys.
default export (ESM)
✓ import createMime from 'simple-mime'; const getMimeType = createMime('application/octet-stream')
✗ import { getMimeType } from 'simple-mime'
The package is primarily CJS, but some bundlers support ESM via default import. Named imports are incorrect.

Shows how to instantiate the mime lookup function with a fallback and query for different files.

var getMimeType = require('simple-mime')('text/plain'); console.log(getMimeType('file.html')); // 'text/html' console.log(getMimeType('file.js')); // 'application/javascript' console.log(getMimeType('file.xyz')); // 'text/plain' (fallback)
Debug
Known issues
gotchaThe module must be called immediately to create the lookup function; otherwise you get a function instead of a value.
fix
Always call require('simple-mime')('your-fallback') to get the proper lookup function.
affects: >=0.0.0
gotchaThe fallback MIME type is required; passing no argument will result in undefined being used as fallback.
fix
Always provide a fallback string like 'application/octet-stream'.
affects: >=0.0.0
deprecatedThe package uses deprecated Node.js APIs (e.g., path.exists) which may cause deprecation warnings in newer Node.js versions.
fix
Consider switching to the more maintained 'mime' package or updating the dependency.
affects: >=0.1.0
Errors
Common errors & fixes
TypeError: object is not a function
Requiring the module without calling it returns a function, not a lookup function.
fix
Change require('simple-mime') to require('simple-mime')('application/octet-stream')
Upgrade
Version history
0.1.0latest on npm
Audit
Dependencies

No dependency data recorded yet.

Agent activity
24 hits · last 30 days
node
22
Anthropic
1
OpenAI (training)
1
Resources
simple-mime — npm install simple-mime · libregistry