{"id":47407,"library":"disk-storage","title":"disk-storage","description":"disk-storage is a Node.js library for storing large amounts of data efficiently on disk. It provides buffer-based reading with cursor support and parallelism, as well as line and batch line reading. Writing is done via append operations. It is designed for high performance and works on Node.js versions 8 and above. The library is stable at version 1.3.2 and is actively maintained on GitHub. It is a lightweight alternative to more complex storage solutions like LevelDB or RocksDB, focusing on simplicity and efficiency for log-like data.","status":"active","version":"1.3.2","language":"javascript","source_language":"en","source_url":"https://github.com/Slawaq/disk-storage","tags":["javascript","disk","storage","logs","persist"],"install":[{"cmd":"npm install disk-storage","lang":"bash","label":"npm"},{"cmd":"yarn add disk-storage","lang":"bash","label":"yarn"},{"cmd":"pnpm add disk-storage","lang":"bash","label":"pnpm"}],"dependencies":[],"imports":[{"note":"ESM import is the preferred method; CommonJS users should use const { DiskStorage } = require('disk-storage').","wrong":"const DiskStorage = require('disk-storage').DiskStorage","symbol":"DiskStorage","correct":"import { DiskStorage } from 'disk-storage'"},{"note":"The library also exports a default export, which is equivalent to the named export DiskStorage.","wrong":"import { default as DiskStorage } from 'disk-storage'","symbol":"default","correct":"import DiskStorage from 'disk-storage'"},{"note":"CommonJS users must destructure the named export; the default export is not available via require.","wrong":"const DiskStorage = require('disk-storage')","symbol":"DiskStorage","correct":"const { DiskStorage } = require('disk-storage')"}],"quickstart":{"code":"import { DiskStorage } from 'disk-storage';\n\nconst storage = new DiskStorage({\n  directory: './data',\n  maxFileSize: 1024 * 1024 * 10, // 10 MB\n});\n\nasync function main() {\n  // Append data\n  await storage.append('Hello, world!\\n');\n  await storage.append('Another line\\n');\n\n  // Read lines\n  const reader = storage.createReader();\n  for await (const line of reader) {\n    console.log(line);\n  }\n\n  // Close storage\n  await storage.close();\n}\n\nmain().catch(console.error);","lang":"typescript","description":"This example shows how to create a DiskStorage instance, append data, and read lines using an async iterator."},"warnings":[{"fix":"Check permissions of the parent directory before creating the storage.","message":"The directory for storage will be created if it does not exist, but ensure the parent directory is writable.","severity":"gotcha","affected_versions":">=1.0"},{"fix":"Use the current option but monitor releases for changes.","message":"The `maxFileSize` option may be deprecated in future versions in favor of a more dynamic limit.","severity":"deprecated","affected_versions":"1.x"},{"fix":"Keep track of the cursor externally if you need to restart reading.","message":"Reading with a cursor requires manual management of the cursor position; resetting the cursor may not be supported.","severity":"gotcha","affected_versions":">=1.0"},{"fix":"Upgrade to Node.js 8 or later.","message":"Node.js 8 is the minimum supported version; earlier versions will result in errors.","severity":"breaking","affected_versions":">=1.0"}],"env_vars":null,"search_vec":"'1.3.2':65 '8':56 'activ':68 'altern':76 'amount':14 'append':43 'base':24 'batch':36 'buffer':23 'buffer-bas':22 'complex':79 'cursor':27 'data':16,95 'design':47 'disk':2,5,19,97 'disk-storag':1,4 'done':41 'effici':17,90 'focus':86 'github':71 'high':49 'javascript':96 'larg':13 'leveldb':83 'librari':10,60 'lightweight':75 'like':82,94 'line':34,37 'log':93,99 'log-lik':92 'maintain':69 'node.js':9,54 'oper':44 'parallel':30 'perform':50 'persist':100 'provid':21 'read':25,38 'rocksdb':85 'simplic':88 'solut':81 'stabl':62 'storag':3,6,80,98 'store':12 'support':28 'version':55,64 'via':42 'well':32 'work':52 'write':39","created_at":"2026-06-07T16:51:22.114207+00:00","updated_at":"2026-06-07T16:51:22.114207+00:00","problems":[{"fix":"Ensure you have the latest version installed: npm install disk-storage@latest and use correct import.","cause":"Using an outdated version of the library or incorrect import.","error":"TypeError: storage.append is not a function"},{"fix":"Run the process with appropriate permissions or change the directory to a writable location.","cause":"Insufficient permissions to create or write to the storage directory.","error":"Error: EACCES: permission denied, open './data/file.log'"},{"fix":"Use CommonJS require: const { DiskStorage } = require('disk-storage'); or set up a transpiler.","cause":"Using ESM syntax in a CommonJS environment without transpilation.","error":"SyntaxError: Unexpected token 'export'"}],"ecosystem":"npm","meta_description":null,"install_score":null,"quickstart_score":null,"quickstart_tag":null,"pypi_latest":null,"cli_name":null,"cli_version":null,"type":"library","homepage":"https://github.com/Slawaq/disk-storage#readme","github":"https://github.com/Slawaq/disk-storage","docs":null,"changelog":null,"pypi":null,"npm":"disk-storage","openapi_spec":null,"status_page":null,"smithery":null,"categories":["storage"],"base_url":null,"auth_type":null,"provenance":{"verified_status":null,"verified_at":null,"last_verified":"2026-06-07","next_check":"2026-09-05","install_tag":null}}