binance-api-node
binance-api-node copied to clipboard
TypeError: Binance is not a function
I am working in a TypeScript project using ES Modules (ESM) and noticed that it doesn't work out-of-the-box with the types provided from binance-api-node/index.d.ts.
Using the following code:
import Binance from 'binance-api-node';
const client = Binance({
apiKey: process.env.BINANCE_API_KEY!,
apiSecret: process.env.BINANCE_API_SECRET!,
});
I ran into this error:
TypeError: Binance is not a function
Here is what I did in my code to fix the situtation:
import Binance from 'binance-api-node';
const esmBinanceHack: typeof Binance = (Binance as any).default;
const client = esmBinanceHack({
apiKey: process.env.BINANCE_API_KEY!,
apiSecret: process.env.BINANCE_API_SECRET!,
});
Is anyone else experiencing a similar problem?
I solved this by deleting my tsconfig file and installing a new one using npx tsconfig.json with option 'node'. B4 that I tried ur solution but lost typechecking and linting.
What is this binance API node anyway?
On Tue, Sep 5, 2023, 2:45 PM OliverLu01 @.***> wrote:
I solved this by deleting my tsconfig file and installed a new one using npx tsconfig.json with option 'node'. B4 that I tried ur solution but lost typechecking and linting.
— Reply to this email directly, view it on GitHub https://github.com/ViewBlock/binance-api-node/issues/640#issuecomment-1707144347, or unsubscribe https://github.com/notifications/unsubscribe-auth/A2V2H6SPHYVK6GFQ5QFKVJ3XY5XK5ANCNFSM6AAAAAA3G42SCE . You are receiving this because you are subscribed to this thread.Message ID: @.***>