Registry / serialization / fs-jetpack

fs-jetpack

JSON →
library5.1.0jsnpmunverified

fs-jetpack provides a more convenient and opinionated API for common file system manipulations, designed as an alternative to Node.js's native `fs` module and `fs-extra`. It is particularly well-suited for scripting, tooling, and build pipelines. Currently at stable version 5.1.0, the library has an active development pace with several minor and major releases in recent years, indicating ongoing maintenance and feature additions. Key differentiators include the ability to create multiple independent Current Working Directories (CWDs) for an object-oriented approach to file operations, first-class support for JSON serialization/deserialization, automatic handling of `ENOENT` errors (creating parent directories as needed and returning `undefined` for non-existent reads), and a consistent `method()` (synchronous) and `methodAsync()` (promise-based asynchronous) naming convention, which deviates from standard Node.js patterns but aims for clarity within the library.

npm install fs-jetpack
INSTALL
IMPORT
SIG · FS-JETPACK
F
fs-jetpack
serializationjavascriptv5.1.0
Install
Import
Disk
Pass rate
0/ 6
Env Coverage0 / 6
glibc
1822
musl
1822
Install & Compatibility
Where this runs
tested against v? · npm install
Install × environment matrix
Each cell = how many times install + import succeeded across repeated harness runs. Partial = flaky.
glibc = Debian/Ubuntu slim · musl = Alpine Linux
musl
node 18226 runs
build_error
glibc
node 18226 runs
build_error
Code
Verified usage

Verified import paths — ran on the pinned version, not inferred.

jetpack
import jetpack from 'fs-jetpack';
import { jetpack } from 'fs-jetpack';
fs-jetpack exports a default instance, not named exports for the main object. Use direct default import for ESM.
jetpack (CommonJS)
const jetpack = require('fs-jetpack');
Standard CommonJS import pattern. This works in older Node.js environments and CJS modules.
FSJetpack (Type)
import type { FSJetpack } from 'fs-jetpack';
Import the `FSJetpack` interface for type annotations, especially when creating custom jetpack instances or extending functionality in TypeScript.

Demonstrates basic synchronous and asynchronous file writes and reads, JSON handling, directory creation, and the chaining API using a temporary directory.

import jetpack from 'fs-jetpack'; import path from 'path'; async function runFsJetpackExample() { // Create a temporary directory for this example const tempDir = jetpack.tmpDir(); const tempDirPath = tempDir.path(); console.log(`Working in temporary directory: ${tempDirPath}`); // Write a simple text file tempDir.write('hello.txt', 'Hello fs-jetpack!\nThis is a synchronous write.'); console.log('Written hello.txt synchronously.'); // Write a JSON object directly const data = { greet: 'World', version: '5.1.0' }; await tempDir.writeAsync('data.json', data); console.log('Written data.json asynchronously.'); // Read the text file synchronously const textContent = tempDir.read('hello.txt'); console.log(`Content of hello.txt: ${textContent}`); // Read the JSON file asynchronously and parse it const jsonData = await tempDir.readAsync('data.json', 'json'); console.log(`Content of data.json: ${JSON.stringify(jsonData)}`); // Create a nested directory and file using chaining tempDir.dir('nested/sub-folder').file('nested.txt', { content: 'This is nested!' }); console.log('Created nested/sub-folder/nested.txt using chaining.'); // List contents of the temporary directory const contents = tempDir.list(); console.log('Contents of temp directory:', contents); // Clean up the temporary directory await tempDir.removeAsync('.'); console.log(`Cleaned up temporary directory: ${tempDirPath}`); } runFsJetpackExample().catch(console.error);
Debug
Known issues
breakingfs-jetpack v5.0.0 and above dropped support for Node.js engines older than v14.
fix
Upgrade your Node.js environment to version 14 or newer, or pin fs-jetpack to a version older than 5.0.0 (e.g., `^4.0.0`).
affects: >=5.0.0
breaking`inspect("some-file", { times: true })` now includes `birthTime` of a file, which might affect applications expecting a specific structure or comparing results.
fix
Review any code that relies on the exact output of `inspect()` with the `times` option and adjust for the presence of `birthTime`.
affects: >=5.0.0
gotchaThe naming convention in fs-jetpack flips the common Node.js pattern: `method()` is synchronous, and `methodAsync()` is asynchronous (returns a Promise).
fix
Always use `methodAsync()` when expecting a Promise and asynchronous behavior. Use `method()` for immediate, synchronous results.
affects: >=0.1.0
gotchaThe internal implementation for recursive file removal (`remove()`/`removeAsync()`) switched from `rimraf` to Node.js native recursive file removal in v5.0.0. While generally compatible, subtle behavioral differences might exist in edge cases (e.g., permissions, symlinks).
fix
Thoroughly test file removal operations when upgrading to v5.0.0 or later, especially in environments with complex file structures or restrictive permissions.
affects: >=5.0.0
Errors
Common errors & fixes
TypeError: jetpack.readAsync is not a function
Attempting to call a method like `read` as an async function, when the synchronous version (`read()`) was intended, or vice-versa expecting a promise from `read()`.
fix
If you need asynchronous behavior (returning a Promise), use `jetpack.readAsync()`. If you need synchronous behavior, use `jetpack.read()`.
SyntaxError: Named export 'jetpack' not found (module 'fs-jetpack')
Trying to import the main fs-jetpack instance using named import syntax for ESM.
fix
fs-jetpack provides a default export. Use `import jetpack from 'fs-jetpack';` for ESM, or `const jetpack = require('fs-jetpack');` for CommonJS.
fs-jetpack: Your Node.js version is too old. Please upgrade to Node.js v14 or newer to use this version of fs-jetpack.
Running fs-jetpack v5.0.0 or newer on a Node.js environment older than v14.
fix
Upgrade your Node.js installation to version 14 or a newer Long Term Support (LTS) release. Alternatively, use an older version of fs-jetpack (e.g., `npm install fs-jetpack@^4.0.0`).
Upgrade
Version history
5.1.0latest on npm
Audit
Dependencies

No dependency data recorded yet.

Agent activity
2 hits · last 30 days
node
2
Resources
fs-jetpack — npm install fs-jetpack · libregistry