#Pradyumna A Kubear

1 messages · Page 1 of 1 (latest)

unique bluffBOT
fringe carbon
#

Hello! Let me bring your screenshot into the thread:

split ravine
#

cool, appreciated

fringe carbon
#

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?

split ravine
#

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

fringe carbon
#

If you comment out line 3 does line 4 work as expected, where you require express?

split ravine
#

line 4 works

#

yes it works when I write const app=express()

fringe carbon
#

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.

split ravine
#

let me just check

#

yup I can see my key

#

sk_test_(SomeKeyName)

fringe carbon
#

Hm. What version of Node are you using?

split ravine
#

18.10.0

fringe carbon
#

What happens if you run this despite the warning?

split ravine
#

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

fringe carbon
#

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?

split ravine
#

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.

fringe carbon
#

That's really strange. It's like require isn't working right.

split ravine
#

yes

fringe carbon
#

If you revert to how the code was before, comment out line 3, and then run it what happens?

split ravine
#

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

fringe carbon
#

No, comment out line 3 and 4, uncomment everything else, then run it.

split ravine
#

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

fringe carbon
#

Okay, so that does work. That means it's not require.

#

Yeah, try removing the Stripe Node library and reinstalling it.

split ravine
#

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

fringe carbon
#

So, hang on. If you remove console.log(stripe) and uncomment line 3 what happens when you run it?

split ravine
#

ok let me see

#

node index.js
Connected to MongoDB
thats it

fringe carbon
#

That seems like it's working?

split ravine
#

I just move my cursor there I am getting the error

#

is it just a warning

fringe carbon
#

I don't know what the warning is about, but it seems to work when you run it.

split ravine
#

ok

#

I will contact you if I again get an error

#

thanks for your patience

#

have a good day

fringe carbon
#

You too!