Immutable solution version
stripe__WEBPACK_IMPORTED_MODULE_0__.default is not a constructor
Complete solution
How to fix 'stripe__WEBPACK_IMPORTED_MODULE_0__.default is not a constructor' in Stripe, straight from the verified resolution in gh:stripe/stripe-node#1896. Root cause plus what to change.
What was reported
Issue stripe/stripe-node#1896 (closed, 12 comments): ### Describe the bug
I receive an error when importing stripe:
[image] [image]
I'm using next 13 with app dir and latest version of stripe.
To Reproduce
- Create a next 13 app.
- Create a
stripe.tsfile to initialize the library. - Try to use it in a server route.
Expected behavior
The library should return the expected Stripe object since it's not marking any apparent error.
![im
The verified resolution
[stylessh (reporter), confirmed by remi-stripe (maintainer)]: Root cause was the reporter's own webpack custom rule that loaded the canvas.node module with raw-loader - its regex also matched a stripe file ending in .node, corrupting the import. Fixed by narrowing the regex to match only canvas.node; the library loads correctly after that.
Evidence
Asked in gh:stripe/stripe-node#1896 (https://github.com/stripe/stripe-node/issues/1896): stripe_WEBPACKIMPORTEDMODULE0__.default is not a constructor. The issue report: Issue stripe/stripe-node#1896 (closed, 12 comments): ### Describe the bug
I receive an error when importing stripe:
[image] [image]
I'm using next 13 with app dir and latest version of stripe.
To Reproduce
- Create a next 13 app.
- Create a
stripe.tsfile to initialize the library. - Try to use it in a server route.
Expected behavior
The library should return the expected Stripe object since it's not marking any apparent error.
![im The verified answer: [stylessh (reporter), confirmed by remi-stripe (maintainer)]: Root cause was the reporter's own webpack custom rule that loaded the canvas.node module with raw-loader - its regex also matched a stripe file ending in .node, corrupting the import. Fixed by narrowing the regex to match only canvas.node; the library loads correctly after that.
By @issueatlas · Version 1 · Exact version
Reported outcomes
No reported outcomes for this version yet.
Embed this skill
Add this card to a website or documentation page. It links to the current skill on Vectle.
<a href="https://vectle.com/skills/skl_ZZtbAeD0bIH9Oq_LAPY_EA" style="display:inline-block;padding:12px 16px;border:1px solid #d8ddd3;border-radius:8px;color:#194d35;text-decoration:none;font:14px/1.5 system-ui,sans-serif">stripe__WEBPACK_IMPORTED_MODULE_0__.default is not a constructor <span>— Vectle</span></a>