{"id":18416,"library":"hfs","title":"HFS: HTTP File Server","description":"HFS (HTTP File Server) is a file-sharing server that turns your computer into a file-sharing hub with unlimited space and bandwidth. Current stable version is 3.1.1 (December 2024), with active development and frequent releases (multiple minor versions per year). Key differentiators include a virtual file system, instant ZIP downloads for large folders, real-time activity monitoring, bandwidth throttling, and a plugin system. It supports HTTPS, WebDAV (since 3.1.0), IPv6, and runs on Windows, Linux, macOS, FreeBSD, and Android. Compared to alternatives like FileZilla or Samba, HFS is lightweight, zero-configuration, and designed for temporary or permanent file sharing over HTTP/HTTPS with a web-based admin interface. It requires Node.js >=18.15.0 and is available as a binary or via npx.","status":"active","version":"3.1.1","language":"javascript","source_language":"en","source_url":"https://github.com/rejetto/hfs","tags":["javascript","file server","http server"],"install":[{"cmd":"npm install hfs","lang":"bash","label":"npm"},{"cmd":"yarn add hfs","lang":"bash","label":"yarn"},{"cmd":"pnpm add hfs","lang":"bash","label":"pnpm"}],"dependencies":[],"imports":[{"note":"HFS v3 is ESM-only. CommonJS require() will fail. The start function is the primary entry point to launch the server programmatically.","wrong":"const hfs = require('hfs'); hfs.start()","symbol":"start","correct":"import { start } from 'hfs'"},{"note":"Hfs is a named export, not default. In v3, there is no default export.","wrong":"import Hfs from 'hfs'","symbol":"Hfs","correct":"import { Hfs } from 'hfs'"},{"note":"Config type/interface for programmatic configuration. Requires TypeScript or JSDoc type imports.","wrong":"const Config = require('hfs').Config","symbol":"Config","correct":"import { Config } from 'hfs'"}],"quickstart":{"code":"import { start } from 'hfs';\n\nconst config = {\n  port: 8080,\n  host: '0.0.0.0',\n  root: './shared',\n  admin: {\n    password: process.env.HFS_ADMIN_PASSWORD ?? 'temp123'\n  }\n};\n\nconst server = await start(config);\nconsole.log('HFS server running on http://localhost:' + config.port);\n\n// To stop: await server.close();","lang":"javascript","description":"Programmatically start an HFS server with custom port, root directory, and admin password using the ESM import."},"warnings":[{"fix":"Update Node.js to version 18.15.0 or later, or use HFS v2.x which supports older Node versions.","message":"HFS v3 requires Node.js >= 18.15.0","severity":"breaking","affected_versions":">=3.0.0"},{"fix":"Use ESM imports (import { start } from 'hfs') or switch to dynamic import() inside CommonJS modules.","message":"HFS v3 is ESM-only; CommonJS require() will throw an error","severity":"breaking","affected_versions":">=3.0.0"},{"fix":"Replace 'vfs' with 'virtualFileSystem' in the config object.","message":"The 'vfs' option in config is deprecated in favor of 'virtualFileSystem'","severity":"deprecated","affected_versions":">=3.1.0"},{"fix":"Run 'config localhost_admin false' in the console or set 'localhostAdmin: false' in config to require authentication from localhost.","message":"Admin panel does not require a password for localhost by default (localhost_admin defaults to true)","severity":"gotcha","affected_versions":"<3.1.0"},{"fix":"Add exception for the HFS binary in your antivirus, or verify the checksum from GitHub releases.","message":"Windows antivirus may flag the HFS binary as a false positive","severity":"gotcha","affected_versions":">=3.0.0"}],"env_vars":null,"last_verified":"2026-04-25T00:00:00.000Z","next_check":"2026-07-24T00:00:00.000Z","problems":[{"fix":"Change your file extension to .mjs or use dynamic import(): const { start } = await import('hfs')","cause":"Using CommonJS require() on an ESM-only package (HFS v3)","error":"Error [ERR_REQUIRE_ESM]: require() of ES Module /path/to/hfs/index.js from /path/to/your/file.js not supported"},{"fix":"Use named import: import { start } from 'hfs'","cause":"Incorrect import: used default import (import hfs from 'hfs') but start is a named export","error":"TypeError: hfs.start is not a function"},{"fix":"Either kill the process using port 8080, or specify a different port in config (e.g., port: 3000)","cause":"Port 8080 is already in use by another process","error":"Error: listen EADDRINUSE :::8080"}],"ecosystem":"npm","meta_description":null,"install_score":null,"install_tag":null,"quickstart_score":null,"quickstart_tag":null}