-
Notifications
You must be signed in to change notification settings - Fork 748
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
stripe__WEBPACK_IMPORTED_MODULE_0__.default is not a constructor #1896
Comments
@stylessh The webpack error makes me think you are importing/using the stripe-node library in your client-side code. The stripe-node library is used server-side for API requests with your Secret API key and it is not compatible with a browser environment. For client-side API requests you would use a separate library called Stripe.js that can either be imported directly or using an npm package and the different options are covered in our docs here. If you're confident this is only happening with your server-side code we would need a way to quickly reproduce this end to end with the exact code you're using! |
@stylessh I paired with someone else on my team to see if they knew what could cause this and they mentioned you might need to change your
to
|
@remi-stripe first, thanks for helping me! I'm pretty sure i'm importing the library on server side, next.js is server first and it executes all the files on the server unless you explicitly set it to client. I'm gonna try changing the tsconfig en let you know |
@stylessh can you give a simple end to end repro? A repo with all the info would help |
Invited you to the repo, check the |
be sure to copy |
this is the video example of the user flow and error |
@stylessh Can you make a clean public repo that has the exact information needed to reproduce the issue? Sorry for the hassle but I'm not the only person helping and getting a clean repro without any manual steps would help. It really should solely be loading stripe-node and nothing specific to your own code/project beyond reproducing the error |
Glad you figured it out and thanks for taking the time to update us with the root cause/fix, that's really appreciated :) |
Exactly the same issue I had, your fix worked for me. Thank you! |
Describe the bug
I receive an error when importing stripe:
I'm using next 13 with app dir and latest version of stripe.
To Reproduce
stripe.ts
file to initialize the library.Expected behavior
The library should return the expected Stripe object since it's not marking any apparent error.
Code snippets
No response
OS
Windows 11
Node version
Node v18.16.0
Library version
"stripe": "12.14.0"
API version
2022-11-15
Additional context
No response
The text was updated successfully, but these errors were encountered: