Почему не работает базовый пример из README?
// stoqey.js
import { ibkr, MarketDataManager } from '@stoqey/ibkr';
await ibkr();
const mkdManager = MarketDataManager.Instance;
const data = await mkdManager.getHistoricalData(
{
symbol: 'AAPL',
secType: 'STK'
},
null,
'1 D',
'1 D',
'TRADES',
true );
console.log(data);
$ node stoqey.js
file:///C:/x/stoqey.js:3
import { ibkr, MarketDataManager } from '@stoqey/ibkr';
^^^^
SyntaxError: Named export 'ibkr' not found. The requested module '@stoqey/ibkr' is a CommonJS module, which may not support all module.exports as named exports.
CommonJS modules can always be imported via the default export, for example using:
import pkg from '@stoqey/ibkr';
const { ibkr, MarketDataManager } = pkg;
at ModuleJob._instantiate (node:internal/modules/esm/module_job:180:21)
at async ModuleJob.run (node:internal/modules/esm/module_job:263:5)
at async onImport.tracePromise.__proto__ (node:internal/modules/esm/loader:578:26)
at async asyncRunEntryPointWithESMLoader (node:internal/modules/run_main:116:5)
Node.js v22.14.0
$ cat package.json
{
"type": "module",
"dependencies": {
"@stoqey/ibkr": "^2.5.8"
}
}
$ cat .env
IBKR_HOST=localhost
IBKR_PORT=4001
IBKR_CLIENT_ID=777
DEBUG=ibkr*
Подробнее здесь: https://stackoverflow.com/questions/798 ... -with-node