#Pradyumna A Kubear
1 messages · Page 1 of 1 (latest)
Hello! Let me bring your screenshot into the thread:
cool, appreciated
According to the error it's not recognizing the Stripe library as something you can run as a function. How did you install the Stripe Node library?
I installed as npm install stripe
npm i stripe
could you please let me know what to do now? should I uninstall and re install the same
If you comment out line 3 does line 4 work as expected, where you require express?
If you log the value of stripe_secret_key is it the key you expect? Don't share it here, just want to make sure it contains your key and isn't blank or anything.
Hm. What version of Node are you using?
18.10.0
What happens if you run this despite the warning?
let me just check
I am just getting a json file
node index.js > message.txt
I have redirected to message
errors: {
generate: [Function: generate],
StripeError: [class StripeError extends Error] { generate: [Function: generate] },
StripeCardError: [class StripeCardError extends StripeError],
StripeInvalidRequestError: [class StripeInvalidRequestError extends StripeError],
StripeAPIError: [class StripeAPIError extends StripeError],
StripeAuthenticationError: [class StripeAuthenticationError extends StripeError],
StripePermissionError: [class StripePermissionError extends StripeError],
StripeRateLimitError: [class StripeRateLimitError extends StripeError],
StripeConnectionError: [class StripeConnectionError extends StripeError],
StripeSignatureVerificationError: [class StripeSignatureVerificationError extends StripeError],
StripeIdempotencyError: [class StripeIdempotencyError extends StripeError],
StripeInvalidGrantError: [class StripeInvalidGrantError extends StripeError],
StripeUnknownError: [class StripeUnknownError extends StripeError]
},
this is the error which I am getting
That is not what I would have expected. 😅
If you change line 3 to just const stripe=require('stripe') and then comment out the rest of the lines and then run it what happens?
errors: {
generate: [Function: generate],
StripeError: [class StripeError extends Error] { generate: [Function: generate] },
StripeCardError: [class StripeCardError extends StripeError],
StripeInvalidRequestError: [class StripeInvalidRequestError extends StripeError],
StripeAPIError: [class StripeAPIError extends StripeError],
StripeAuthenticationError: [class StripeAuthenticationError extends StripeError],
StripePermissionError: [class StripePermissionError extends StripeError],
StripeRateLimitError: [class StripeRateLimitError extends StripeError],
StripeConnectionError: [class StripeConnectionError extends StripeError],
StripeSignatureVerificationError: [class StripeSignatureVerificationError extends StripeError],
StripeIdempotencyError: [class StripeIdempotencyError extends StripeError],
StripeInvalidGrantError: [class StripeInvalidGrantError extends StripeError],
StripeUnknownError: [class StripeUnknownError extends StripeError]
},
I am getting the error along with other json elements
like stripe resource, transaction,transactionEntries etc.
That's really strange. It's like require isn't working right.
yes
If you revert to how the code was before, comment out line 3, and then run it what happens?
require('dotenv').config()
stripe_secret_key=process.env.STRIPE_SECRET_KEY
const stripe=require('stripe')(stripe_secret_key)
console.log(stripe)
// const express=require("express");
// const bodyParser=require("body-parser")
// const cors=require("cors")
//
// const db=require("./db");
//
// const app=express();
in this which should I comment?
I really appreciate your patience
and time
No, comment out line 3 and 4, uncomment everything else, then run it.
require('dotenv').config()
stripe_secret_key=process.env.STRIPE_SECRET_KEY
// const stripe=require('stripe')(stripe_secret_key)
// console.log(stripe)
const express=require("express");
const bodyParser=require("body-parser")
const cors=require("cors")
const db=require("./db");
const app=express();
I ran this it is running
it is running
Okay, so that does work. That means it's not require.
Yeah, try removing the Stripe Node library and reinstalling it.
ok
let me try it
I did npm uninstall stripe
and later npm install stripe
again the same error
Method expression is not of Function type
So, hang on. If you remove console.log(stripe) and uncomment line 3 what happens when you run it?
That seems like it's working?
I don't know what the warning is about, but it seems to work when you run it.
ok
I will contact you if I again get an error
thanks for your patience
have a good day
You too!