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

Named export <nameExport> not found #183

Closed
innovaweb-dev opened this issue Jul 9, 2022 · 2 comments
Closed

Named export <nameExport> not found #183

innovaweb-dev opened this issue Jul 9, 2022 · 2 comments

Comments

@innovaweb-dev
Copy link

innovaweb-dev commented Jul 9, 2022

Hello,
I tried to learn @node-ts/bus, but I can't import anything.
I want just to reproduce this https://bus.node-ts.com/installing/handling-messages

import { Command } from '@node-ts/bus-messages';
SyntaxError: Named export 'Command' not found. The requested module '@nod
e-ts/bus-messages' is a CommonJS module, which may not support all module.exports as named exports.

I tried "type": "commonjs" instead "type": "module" in my package.json

import { Bus } from '@node-ts/bus-core';
 SyntaxError: Cannot use import statement outside a module

What I can do to fix it ?
Thanks


Node.js v18.4.0
pnpm 7.4.1
TypeScript 4.7.4

@innovaweb-dev
Copy link
Author

Temporary solution :

import pkg from '@node-ts/bus-core'
const {handlerFor}= pkg;

@adenhertog
Copy link
Contributor

hi @rifton007, it's perhaps too late by now but it looked like you were importing @node-ts/bus-messages into an ES modules-based package. There's nothing specific about the bus-messages library - it's a commonjs module.

I don't yet have a plan to move the library to ES modules, though I may end up transpiling to both. For now your temporary solution seems to be the way to go.

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

2 participants