node-fs: Legacy FS Extension

0.1.7 · abandoned · verified Sun Apr 19

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.

Common errors

Warnings

Install

Imports

Quickstart

Demonstrates `node-fs`'s recursive directory creation and file copying features, then cleans up using modern Node.js `fs` methods.

const fs = require('node-fs');
const path = require('path');

const dirToCreate = path.join(__dirname, 'test-dir-legacy/sub-dir');
const fileToCopy = path.join(__dirname, 'test-file.txt');
const copiedFile = path.join(__dirname, 'test-dir-legacy/copied-file.txt');

// Create a dummy file for copying
require('fs').writeFileSync(fileToCopy, 'Hello from the past!');

console.log('Attempting to create directory recursively with node-fs...');
fs.createDirectory(dirToCreate, 0o777, true, (err) => {
  if (err) {
    console.error('Error creating directory:', err);
    return;
  }
  console.log(`Directory created: ${dirToCreate}`);

  console.log('Attempting to copy file with node-fs...');
  fs.copy(fileToCopy, copiedFile, (err) => {
    if (err) {
      console.error('Error copying file:', err);
      return;
    }
    console.log(`File copied from ${fileToCopy} to ${copiedFile}`);

    // Clean up (using modern fs for robust cleanup)
    console.log('Cleaning up...');
    require('fs').unlinkSync(fileToCopy);
    require('fs').unlinkSync(copiedFile);
    require('fs').rmdirSync(path.dirname(dirToCreate), { recursive: true });
    console.log('Cleanup complete.');
  });
});

view raw JSON →