klover2 / wechatpay-node-v3-ts

微信支付v3
MIT License
533 stars 83 forks source link

[Bug] wechatpay_node_v3_1.default is not a constructor #20

Closed AnCoSONG closed 2 years ago

AnCoSONG commented 2 years ago

import WxPay from 'wechatpay-node-v3' fails and show error like this wechatpay_node_v3_1.default is not a constructor.

Currently I fix this problem by editing the node module with following codes:

// in index.d.js
export = Pay;
export default Pay; // add this

// in index.js
module.exports = Pay;
module.exports.default = Pay; // add this
klover2 commented 2 years ago

import WxPay from 'wechatpay-node-v3' fails and show error like this wechatpay_node_v3_1.default is not a constructor.

Currently I fix this problem by editing the node module with following codes:

// in index.d.js
export = Pay;
export default Pay; // add this

// in index.js
module.exports = Pay;
module.exports.default = Pay; // add this

你用的是不是nestjs框架,他这个有个特殊的类型检查,推荐先用require过渡一下,我正在集成把当前npm包集成nestjs

klover2 commented 1 year ago

已经支持好了 npm install nest-wechatpay-node-v3