{"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,"last_verified":"2026-04-25T00:00:00.000Z","next_check":"2026-07-24T00:00:00.000Z","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,"install_tag":null,"quickstart_score":null,"quickstart_tag":null}