The `oss-client` package provides a robust Node.js client for Alibaba Cloud's Object Storage Service (OSS), functionally similar to Amazon S3. The current stable version is 2.5.1, released in August 2025. This library maintains an active release cadence, with minor feature updates every few months and bug fixes as needed. It leverages modern JavaScript features, exclusively using `async/await` for all operations, making asynchronous programming straightforward. A key differentiator is its strong TypeScript support and ESM-first approach since version 2.0.0, catering to contemporary Node.js development practices. It is specifically designed for Aliyun OSS, offering comprehensive object manipulation capabilities including put, get, delete, stream handling, URL generation, and ACL management, along with support for bucket and object tagging.
npm install oss-clientVerified import paths — ran on the pinned version, not inferred.
Demonstrates initializing the OSS client, uploading a file, retrieving its content, and then deleting the object using async/await.
Upgrade Node.js to version 16.0.0 or higher, or pin `oss-client` to version `1.x`.
Refactor code to remove usage of `stsToken`, `headerEncoding`, and `Bucket`/`Image Client` specific APIs. Consult Aliyun OSS documentation for alternative approaches for STS or image processing.
Ensure `urllib` is compatible with your project's ecosystem. Review `urllib` v4.x release notes for any breaking changes that might affect your direct `urllib` usage, if any.
Replace all calls to `client.getObjectUrl(name)` with `client.generateObjectUrl(name)`.
Always handle stream errors and ensure streams are properly piped or consumed and closed. Consider using `pipeline` from `node:stream/promises` for robust stream handling.
Ensure your project is configured for ESM (e.g., `"type": "module"` in `package.json`) and use `import { OSSObject } from 'oss-client';`. Alternatively, for older Node.js or strict CommonJS environments, consider `oss-client` v1.x.Verify that `new OSSObject({...})` is correctly called and that `OSSObject` is properly imported. Check the method signature and available methods against the documentation for your `oss-client` version.Double-check your `accessKeyId`, `accessKeySecret`, `region`, and `bucket` configurations for typos. Ensure the keys have the necessary permissions for the operations being performed. If using temporary credentials, verify their validity.