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.
FlyDrive
✓ import { FlyDrive } from 'flydrive'
✗ const FlyDrive = require('flydrive')
FlyDrive is ESM-only since v2. CommonJS require will fail.
fsDriver
✓ import { fsDriver } from 'flydrive/drivers/fs'
✗ import { fsDriver } from 'flydrive'
Drivers are exported from subpaths, not the main entry.
s3Driver
✓ import { s3Driver } from 'flydrive/drivers/s3'
✗ import { s3Driver } from 'flydrive'
S3 driver must be imported from the dedicated subpath.
gcsDriver
✓ import { gcsDriver } from 'flydrive/drivers/gcs'
✗ import { gcsDriver } from 'flydrive'
GCS driver is exported from the gcs subpath.
Shows how to instantiate filesystem, S3, and GCS drivers and perform basic file operations like put, get, getUrl, getSignedUrl, and exists.
import { FlyDrive } from 'flydrive'
import { fsDriver } from 'flydrive/drivers/fs'
import { s3Driver } from 'flydrive/drivers/s3'
import { GcsDriver } from 'flydrive/drivers/gcs'
// Filesystem driver
const fs = new FlyDrive({
driver: fsDriver({
location: './storage',
visibility: 'private',
appUrl: 'http://localhost:3333'
})
})
await fs.put('hello.txt', 'Hello world')
const content = await fs.get('hello.txt')
console.log(content)
// S3 driver
const s3 = new FlyDrive({
driver: s3Driver({
credentials: {
accessKeyId: process.env.AWS_ACCESS_KEY_ID ?? '',
secretAccessKey: process.env.AWS_SECRET_ACCESS_KEY ?? ''
},
region: 'us-east-1',
bucket: 'my-bucket'
})
})
await s3.put('file.txt', 'Buffer or string', { contentType: 'text/plain' })
const url = await s3.getUrl('file.txt')
const signedUrl = await s3.getSignedUrl('file.txt', { expiresIn: '30mins' })
console.log({ url, signedUrl })
// GCS driver
const gcs = new FlyDrive({
driver: new GcsDriver({
keyFilename: '/path/to/key.json',
bucket: 'my-gcs-bucket'
})
})
await gcs.put('data.json', JSON.stringify({ key: 'value' }))
const exists = await gcs.exists('data.json')
console.log(exists)
Errors
Common errors & fixes
Error [ERR_REQUIRE_ESM]: require() of ES Module .../node_modules/flydrive/build/index.js from ... not supported. Instead change the require of index.js to a dynamic import() which is available in all CommonJS modules.
Using require() on an ESM-only package.
fixReplace require() with import or set type: module in package.json and use ESM syntax.
Module not found: Error: Can't resolve 'flydrive/drivers/fs'
Attempting to import a driver from the wrong path (e.g., 'flydrive').
fixUse the correct subpath: 'flydrive/drivers/fs', 'flydrive/drivers/s3', or 'flydrive/drivers/gcs'.
ERR_PACKAGE_PATH_NOT_EXPORTED: Package subpath './dist/drivers/fs' is not defined by 'exports' in .../node_modules/flydrive/package.json
Using an old import path with 'dist/' subdirectory.
fixRemove 'dist/' from path: import from 'flydrive/drivers/fs'.
Audit
Dependencies
@aws-sdk/client-s3optionalRequired for S3 driver to interact with AWS S3 API
@aws-sdk/s3-request-presigneroptionalRequired for S3 signed URL generation
@google-cloud/storageoptionalRequired for GCS driver to interact with Google Cloud Storage API