{"id":18788,"library":"simple-mime","title":"simple-mime","description":"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.","status":"active","version":"0.1.0","language":"javascript","source_language":"en","source_url":"http://github.com/creationix/simple-mime","tags":["javascript"],"install":[{"cmd":"npm install simple-mime","lang":"bash","label":"npm"},{"cmd":"yarn add simple-mime","lang":"bash","label":"yarn"},{"cmd":"pnpm add simple-mime","lang":"bash","label":"pnpm"}],"dependencies":[],"imports":[{"note":"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.","wrong":"const mime = require('simple-mime')","symbol":"default","correct":"var getMimeType = require('simple-mime')('application/octet-stream')"},{"note":"The returned function expects a filename or extension string. Do not treat it as an object with extension keys.","wrong":"var type = getMimeType['mp3']","symbol":"lookup function","correct":"var type = getMimeType('file.mp3')"},{"note":"The package is primarily CJS, but some bundlers support ESM via default import. Named imports are incorrect.","wrong":"import { getMimeType } from 'simple-mime'","symbol":"default export (ESM)","correct":"import createMime from 'simple-mime'; const getMimeType = createMime('application/octet-stream')"}],"quickstart":{"code":"var getMimeType = require('simple-mime')('text/plain');\nconsole.log(getMimeType('file.html')); // 'text/html'\nconsole.log(getMimeType('file.js'));   // 'application/javascript'\nconsole.log(getMimeType('file.xyz'));  // 'text/plain' (fallback)","lang":"javascript","description":"Shows how to instantiate the mime lookup function with a fallback and query for different files."},"warnings":[{"fix":"Always call require('simple-mime')('your-fallback') to get the proper lookup function.","message":"The module must be called immediately to create the lookup function; otherwise you get a function instead of a value.","severity":"gotcha","affected_versions":">=0.0.0"},{"fix":"Always provide a fallback string like 'application/octet-stream'.","message":"The fallback MIME type is required; passing no argument will result in undefined being used as fallback.","severity":"gotcha","affected_versions":">=0.0.0"},{"fix":"Consider switching to the more maintained 'mime' package or updating the dependency.","message":"The package uses deprecated Node.js APIs (e.g., path.exists) which may cause deprecation warnings in newer Node.js versions.","severity":"deprecated","affected_versions":">=0.1.0"}],"env_vars":null,"search_vec":"'0.1.0':24 'current':27 'depend':37 'dependency-fre':36 'extens':19 'featur':43 'feature-rich':42 'file':18,51 'focus':31 'free':38 'function':15 'ideal':47 'javascript':57 'librari':9 'lightweight':34 'lookup':8 'map':17 'mime':3,6,21,45 'minim':5,54 'node.js':11 'packag':46 'prefer':56 'provid':12 'releas':29 'rich':44 'server':52 'simpl':2,14 'simple-mim':1 'small':49 'stabl':28 'static':50 'type':7,22 'unlik':39 'version':23","created_at":"2026-04-25T07:40:07.680641+00:00","updated_at":"2026-04-25T07:40:07.680641+00:00","problems":[{"fix":"Change require('simple-mime') to require('simple-mime')('application/octet-stream')","cause":"Requiring the module without calling it returns a function, not a lookup function.","error":"TypeError: object is not a function"}],"ecosystem":"npm","meta_description":null,"install_score":null,"quickstart_score":null,"quickstart_tag":null,"pypi_latest":null,"cli_name":"","cli_version":null,"type":"library","homepage":null,"github":"https://github.com/creationix/simple-mime","docs":null,"changelog":null,"pypi":null,"npm":"https://www.npmjs.com/package/simple-mime","openapi_spec":null,"status_page":null,"smithery":null,"categories":["serialization","http-networking"],"base_url":null,"auth_type":null,"provenance":{"verified_status":null,"verified_at":null,"last_verified":"2026-06-17","next_check":"2026-07-24","install_tag":null}}