aliyun / aliyun/credentials-nodejs
TypeError: Credential is not a constructor,请支持 ESM
Open
Nobody has claimed this yet.
- Dominant language
- TypeScript
- Stars
- 15
- Forks
- 16
- PR merge metrics
- No merged PRs in 30d
Description
new Credential 报错,new Credential.default 成功。
重现步骤:
运行 node main.js
// main.js
import Credential, { Config } from '@alicloud/credentials';
const config = new Config({
type: 'access_key', // credential type
accessKeyId: 'accessKeyId', // AccessKeyId of your account
accessKeySecret: 'accessKeySecret', // AccessKeySecret of your account
})
const cred = new Credential(config); // TypeError: Credential is not a constructor.
// const cred = new Credential.default(config); // 能正常运行
@alicoud/ 下的一些库都有同样的问题,比如 @alicloud/dysmsapi20170525:
import Dysmsapi20170525 from '@alicloud/dysmsapi20170525';
new Dysmsapi20170525(config) // 报 TypeError: Dysmsapi20170525 is not a constructor
相关问题 https://github.com/aliyun/credentials-nodejs/issues/139
Contributor guide
No contributing guide indexed for this repository
First steps
- Read the whole issue, then the project's contributing guide.
- Comment on the issue to say you are picking it up — it saves two people doing the same work.
- Fork the repository and make your change on a branch.
- Open a pull request that references the issue number.
Research direction
Start with the ESM import and constructor call in main.js, comparing the failing default import with the working .default form. Review the related issue 139 for context. Done means the shown Credential and Dysmsapi20170525 constructor calls work under ESM without .default.
Written by the indexing model from the issue text.
Assessment
- Tech stack
- nodejs, typescript
- Domain
- authentication
- Issue type
- Bug
- Difficulty
- 3/5
- Estimated time
- 1-2 days
- Activity status
- Quiet
- Clarity
- Mostly clear
- Newbie friendliness
- 55/100