Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Cannot import into ES6 node module #12

Open
bunchjesse opened this issue Aug 30, 2024 · 2 comments
Open

Cannot import into ES6 node module #12

bunchjesse opened this issue Aug 30, 2024 · 2 comments

Comments

@bunchjesse
Copy link

bunchjesse commented Aug 30, 2024

See sample project

Using the code in your README:

root@2f3496033380:/app# node main.js 
file:///app/main.js:1
import { DXLinkWebSocketClient, DXLinkFeed } from '@dxfeed/dxlink-api'
                                ^^^^^^^^^^
SyntaxError: Named export 'DXLinkFeed' not found. The requested module '@dxfeed/dxlink-api' 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 '@dxfeed/dxlink-api';
const { DXLinkWebSocketClient, DXLinkFeed } = pkg;

    at ModuleJob._instantiate (node:internal/modules/esm/module_job:146:21)
    at async ModuleJob.run (node:internal/modules/esm/module_job:229:5)
    at async ModuleLoader.import (node:internal/modules/esm/loader:473:24)
    at async asyncRunEntryPointWithESMLoader (node:internal/modules/run_main:123:5)

Node.js v20.17.0

OK, so I should be able to do this then, right?

import dxLink from '@dxfeed/dxlink-api'

Nope:

/app/node_modules/@dxfeed/dxlink-api/build/index.module.js:1
export*from"@dxfeed/dxlink-core";export*from"@dxfeed/dxlink-feed";export*from"@dxfeed/dxlink-websocket-client";export*from"@dxfeed/dxlink-dom";
^^^^^^

SyntaxError: Unexpected token 'export'
    at wrapSafe (node:internal/modules/cjs/loader:1378:20)
    at Module._compile (node:internal/modules/cjs/loader:1428:41)
    at Module._extensions..js (node:internal/modules/cjs/loader:1548:10)
    at Module.load (node:internal/modules/cjs/loader:1288:32)
    at Module._load (node:internal/modules/cjs/loader:1104:12)
    at cjsLoader (node:internal/modules/esm/translators:346:17)
    at ModuleWrap.<anonymous> (node:internal/modules/esm/translators:286:7)
    at ModuleJob.run (node:internal/modules/esm/module_job:234:25)
    at async ModuleLoader.import (node:internal/modules/esm/loader:473:24)
    at async asyncRunEntryPointWithESMLoader (node:internal/modules/run_main:123:5)
@demansou
Copy link

demansou commented Sep 20, 2024

Also have this issue

As @dxfeed/dxlink-api is an aggregate package, I also attempted to install @dxfeed/dxlink-websocket-client@0.3.0 and received the same inability to import the DXLinkWebSocketClient.

This package is unusable in its current state which is unfortunate.

@kwabe007
Copy link

kwabe007 commented Oct 1, 2024

I just came across the same problem while trying to use the package. Any updates from the devs?

Edit
Ended up just copying the source code of the individual packages: dxlink-core, dxlink-dom, dxlink-feed and dxlink-websocket-client into my project.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

3 participants