{"id":14736,"library":"node-fs","title":"node-fs: Legacy FS Extension","description":"node-fs is an extension library for Node.js's native `fs` module, originally designed for very early Node.js versions (specifically, requiring Node.js >=0.1.97). It aimed to provide functionalities that were not natively available in the `fs` module at the time, such as recursive directory creation (`fs.createDirectory`, `fs.mkdirSyncRecursive`) and recursive directory removal (`fs.remove`, `fs.rmdirSyncRecursive`), as well as recursive directory watching (`fs.watchTree`). The package's last update was in 2011, and it reached version 0.1.7. Given the significant advancements in Node.js's native `fs` module (e.g., recursive options for `fs.mkdir` and `fs.rm` are standard since Node.js v10.12.0 and v12.10.0 respectively), `node-fs` is now obsolete. Modern Node.js versions provide these features natively, making this package unnecessary and incompatible with current development practices. It has no ongoing maintenance or active development.","status":"abandoned","version":"0.1.7","language":"javascript","source_language":"en","source_url":"git://github.com/bpedro/node-fs","tags":["javascript"],"install":[{"cmd":"npm install node-fs","lang":"bash","label":"npm"},{"cmd":"yarn add node-fs","lang":"bash","label":"yarn"},{"cmd":"pnpm add node-fs","lang":"bash","label":"pnpm"}],"dependencies":[],"imports":[{"note":"This package exclusively uses CommonJS `require()` due to its age (Node.js 0.1.x era) and is incompatible with ESM `import` statements. The module exports an extended `fs` object.","wrong":"import { fs } from 'node-fs';","symbol":"fs","correct":"const fs = require('node-fs');"},{"note":"The module extends the global `fs` object or returns an object with extended methods; individual functions are not typically destructured from the `require` call in this old CommonJS pattern. The `createDirectory` method has been superseded by `fs.mkdir(path, { recursive: true })` in modern Node.js.","wrong":"const { createDirectory } = require('node-fs');","symbol":"createDirectory","correct":"const fs = require('node-fs');\nfs.createDirectory('./path/to/dir', 0o777, (err) => { /* ... */ });"},{"note":"This method for recursive deletion has been superseded by `fs.rm(path, { recursive: true, force: true })` in modern Node.js, with `fs.rmdir({ recursive: true })` being deprecated.","wrong":"require('node-fs').remove('./path');","symbol":"remove","correct":"const fs = require('node-fs');\nfs.remove('./path/to/remove', (err) => { /* ... */ });"}],"quickstart":{"code":"const fs = require('node-fs');\nconst path = require('path');\n\nconst dirToCreate = path.join(__dirname, 'test-dir-legacy/sub-dir');\nconst fileToCopy = path.join(__dirname, 'test-file.txt');\nconst copiedFile = path.join(__dirname, 'test-dir-legacy/copied-file.txt');\n\n// Create a dummy file for copying\nrequire('fs').writeFileSync(fileToCopy, 'Hello from the past!');\n\nconsole.log('Attempting to create directory recursively with node-fs...');\nfs.createDirectory(dirToCreate, 0o777, true, (err) => {\n  if (err) {\n    console.error('Error creating directory:', err);\n    return;\n  }\n  console.log(`Directory created: ${dirToCreate}`);\n\n  console.log('Attempting to copy file with node-fs...');\n  fs.copy(fileToCopy, copiedFile, (err) => {\n    if (err) {\n      console.error('Error copying file:', err);\n      return;\n    }\n    console.log(`File copied from ${fileToCopy} to ${copiedFile}`);\n\n    // Clean up (using modern fs for robust cleanup)\n    console.log('Cleaning up...');\n    require('fs').unlinkSync(fileToCopy);\n    require('fs').unlinkSync(copiedFile);\n    require('fs').rmdirSync(path.dirname(dirToCreate), { recursive: true });\n    console.log('Cleanup complete.');\n  });\n});","lang":"javascript","description":"Demonstrates `node-fs`'s recursive directory creation and file copying features, then cleans up using modern Node.js `fs` methods."},"warnings":[{"fix":"Do not use this package. Migrate to native Node.js `fs` module functionalities. For recursive directory creation, use `fs.mkdir(path, { recursive: true })`. For recursive directory removal, use `fs.rm(path, { recursive: true, force: true })`.","message":"This package is entirely incompatible with modern Node.js versions (v10+). Its functionalities are either natively implemented or have different, incompatible APIs in current Node.js releases. Attempting to use it will lead to runtime errors or unexpected behavior.","severity":"breaking","affected_versions":">=1.0.0 (Node.js)"},{"fix":"Immediately remove this package from your dependencies and refactor code to use modern Node.js `fs` features or well-maintained third-party alternatives like `fs-extra` if additional utility functions are required.","message":"The package is abandoned, with its last commit in 2011. It receives no maintenance, security updates, or bug fixes, making it a significant security risk for any application still using it.","severity":"breaking","affected_versions":">=0.1.7"},{"fix":"Rewrite code to use Node.js's native `fs.mkdir(path, { recursive: true })` (since v10.12.0) and `fs.rm(path, { recursive: true })` (since v14.14.0 for `fs.rmdir` or preferred `fs.rm` for file/directory).","message":"Many functionalities provided by `node-fs`, such as recursive `mkdir` and `rmdir`, were eventually integrated into the native Node.js `fs` module with a different API signature and improved behavior. The `node-fs` API is effectively deprecated by native `fs` advancements.","severity":"deprecated","affected_versions":">=0.1.7"},{"fix":"Replace `fs.watchTree` with `fs.watch` from the native Node.js `fs` module, or use a robust third-party watcher library that handles complexities (e.g., `chokidar`).","message":"The `fs.watchTree` method provided by this package is an inefficient and unreliable pattern for file system watching. Modern Node.js provides `fs.watch` which is more performant and robust, though still has platform-specific caveats.","severity":"gotcha","affected_versions":">=0.1.7"},{"fix":"Avoid using packages that monkey-patch or globally extend core Node.js modules. Prefer modular libraries that export their functionalities clearly or use native Node.js features.","message":"This package explicitly extends the Node.js `fs` module in a way that can lead to conflicts or unexpected behavior if other libraries also try to extend `fs` or if Node.js updates introduce new `fs` methods with the same names.","severity":"gotcha","affected_versions":">=0.1.7"}],"env_vars":null,"last_verified":"2026-04-19T00:00:00.000Z","next_check":"2026-07-18T00:00:00.000Z","problems":[{"fix":"Ensure you are requiring `node-fs` correctly (`const fs = require('node-fs');`). However, the real fix is to stop using this abandoned package and migrate to native Node.js `fs` methods like `fs.mkdir(path, { recursive: true })`.","cause":"Attempting to use `fs.createDirectory` (or other `node-fs` methods) after requiring the native Node.js 'fs' module, or after `node-fs` failed to load/patch 'fs'.","error":"TypeError: fs.createDirectory is not a function"},{"fix":"Install the package via `npm install node-fs`. However, it's strongly recommended NOT to use this abandoned package. Instead, refactor your code to use the native `fs` module.","cause":"The `node-fs` package is not installed in `node_modules` or Node.js cannot resolve the module path.","error":"Error: Cannot find module 'node-fs'"},{"fix":"Ensure the Node.js process has write permissions to the target directory. On Linux/macOS, check file permissions with `ls -l` and use `chmod` if necessary. On Windows, verify folder security settings. This error is not specific to `node-fs` but common for any file system operation.","cause":"The Node.js process does not have sufficient permissions to create a directory or file at the specified path, which is a common operating system permission error.","error":"Error: EACCES: permission denied, mkdir 'some/path'"}],"ecosystem":"npm"}