Registry / storage / netstorage

netstorage

JSON →
library3.1.2jsnpmunverified

A TypeScript API and CLI for the Akamai NetStorage REST interface. Current stable version is 3.1.2, released with ESM-only support. The package provides both programmatic API and a rich CLI with features like bi-directional sync, recursive operations, interactive REPL with tab-completion, built-in retries and rate limiting. It is fully typed and focuses on developer experience with dry-run mode and size aggregation tools. Differentiates itself by being the only maintained TypeScript SDK for Akamai NetStorage with CLI parity.

npm install netstorage
INSTALL
IMPORT
SIG · NETSTORAGE
N
netstorage
storagejavascriptv3.1.2
harness data pending
Install & Compatibility
Where this runs

No compatibility data collected yet for this library.

Code
Verified usage

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

createConfig
import { createConfig } from 'netstorage'
const { createConfig } = require('netstorage')
Package is ESM-only; CommonJS require will throw an error. Use dynamic import() if needed.
uploadDirectory
import { uploadDirectory } from 'netstorage'
const uploadDirectory = require('netstorage').uploadDirectory
As with all exports, must use ESM import.
downloadDirectory
import { downloadDirectory } from 'netstorage'
No common mistake beyond ESM vs CJS mismatch.
createConfig type
import type { NetStorageConfig } from 'netstorage'
import { NetStorageConfig } from 'netstorage'
NetStorageConfig is a type, not a value. Use import type to avoid runtime error.
listDirectory
import { listDirectory } from 'netstorage'
import { ls } from 'netstorage'
The library does not export 'ls'; use listDirectory for directory listing.

Bi-directional sync between a local directory and a remote Akamai NetStorage path, using dotenv for credentials.

import { createConfig, syncDirectory } from 'netstorage'; import dotenv from 'dotenv'; dotenv.config(); const config = createConfig({ key: process.env.NETSTORAGE_KEY ?? '', keyName: process.env.NETSTORAGE_KEY_NAME ?? '', host: process.env.NETSTORAGE_HOST ?? '', cpCode: process.env.NETSTORAGE_CP_CODE ?? '', }); async function main() { try { await syncDirectory(config, { localPath: './local-data', remotePath: '/remote-data', delete: true, // mirror deletion between local and remote }); console.log('Sync completed successfully'); } catch (error) { console.error('Sync failed:', error); } } main();
Debug
Known issues
breakingVersion 3.0.0 dropped CommonJS support entirely; the package is now ESM-only.
fix
If you use require(), migrate to import or dynamic import(). For Node.js, set "type": "module" in package.json, or use .mjs extension.
affects: >=3.0.0
deprecatedThe CLI command 'auth' and REPL auth workflow are deprecated in favor of 'config' commands.
fix
Use 'npx netstorage config set' instead of 'npx netstorage auth'.
affects: >=3.1.0
breakingIn version 3.0.0, the API method 'uploadFile' signature changed: it now expects an options object instead of multiple arguments.
fix
Update calls to uploadFile(config, {localPath, remotePath, ...}) instead of uploadFile(config, localPath, remotePath).
affects: >=3.0.0
gotchaRate limiting is enabled by default; if you hit Akamai limits, the library will retry but may appear slow.
fix
Adjust rate limit settings via createConfig({maxRetries, retryDelay}) or set highWaterMark for streams.
affects: >=3.0.0
gotchaThe REPL uses a working directory context; commands like 'upload' default to current remote directory, not root.
fix
Use 'pwd' to see current remote directory. Use absolute paths starting with '/' to avoid context issues.
affects: >=3.0.0
gotchaEnvironment variables are not automatically loaded; you must use dotenv or similar before calling createConfig.
fix
Install dotenv and call dotenv.config() at entry point, or hardcode credentials (not recommended).
affects: >=3.0.0
Errors
Common errors & fixes
Error [ERR_REQUIRE_ESM]: require() of ES Module /path/to/netstorage/dist/index.js from /path/your.js not supported.
Using CommonJS require() on an ESM-only package.
fix
Use import instead: change 'require("netstorage")' to 'await import("netstorage")'. Also ensure your project is ESM or use dynamic import.
TypeError: createConfig is not a function
Attempting to call createConfig without importing it (e.g., using default import mistakenly).
fix
Use named import: import { createConfig } from 'netstorage'. Do not use import netstorage from 'netstorage'.
Error: Missing required credentials: key, keyName, host, cpCode
createConfig missing one or more required properties.
fix
Ensure all four fields are provided in the config object. Use environment variables as shown in the quickstart.
Error 403 Forbidden: Access denied
Akamai NetStorage credentials are invalid or CP code is incorrect.
fix
Verify your key, keyName, host, and cpCode. Use 'npx netstorage config show' to check current configuration.
Error: stream is not readable or end() called with data in iterative write
Attempting to upload a file that doesn't exist or is a directory.
fix
Check that the local path points to a file, not a directory. Use uploadDirectory for directories.
Upgrade
Version history
3.1.2latest on npm
Audit
Dependencies

No dependency data recorded yet.

Agent activity
32 hits · last 30 days
node
28
Amazon
1
OpenAI (training)
1
Resources