praneeth mendu
praneeth mendu

Reputation: 409

In JS can I require() only an export from a module?

In other words can I do this :

import Binance from 'binance-api-node'

const client = Binance()

with a require() statement ??

The above code needs to be in a small module I have to write so I cannot use import

Upvotes: 1

Views: 424

Answers (2)

barro32
barro32

Reputation: 2708

If you want to use ES modules try this:

import Binance from 'binance-api-node'
const client = Binance.default()

Upvotes: 2

Yoann N
Yoann N

Reputation: 51

const Binance = require('binance-api-node').default;

const client = Binance();

Upvotes: 2

Related Questions