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

Error: Dynamic require of "path" is not supported #570

Closed
pedropmedina opened this issue May 15, 2023 · 15 comments
Closed

Error: Dynamic require of "path" is not supported #570

pedropmedina opened this issue May 15, 2023 · 15 comments

Comments

@pedropmedina
Copy link

Hi, I'm getting the following error Error: Dynamic require of "path" is not supported when type: module in package.json. Does the library supports esm ?

@felixmosh
Copy link
Owner

How does ot related? From what I know, if your project uses esm, it can consume cjs, am I right?

@pedropmedina
Copy link
Author

pedropmedina commented May 15, 2023

Yeah, that's what I thought @felixmosh , but I'm getting that error for some reason. Here's the stack trace:

Error: Dynamic require of "path" is not supported at file:///Users/pedropmedina/code/ricoma/ricoma/dist/apps/netsuite/api/main.js:12:9 at node_modules/@bull-board/api/dist/src/index.js (file:///Users/pedropmedina/code/ricoma/ricoma/node_modules/@bull-board/api/src/index.ts:1:1) at __require2 (file:///Users/pedropmedina/code/ricoma/ricoma/dist/apps/netsuite/api/main.js:15:50) at file:///Users/pedropmedina/code/ricoma/ricoma/apps/netsuite/api/src/main.ts:11:33 at ModuleJob.run (node:internal/modules/esm/module_job:194:25)

@felixmosh
Copy link
Owner

What is the line that it complains on?

@pedropmedina
Copy link
Author

pedropmedina commented May 15, 2023

This one @felixmosh import { BullMQAdapter } from '@bull-board/api/bullMQAdapter.js';

If I don't add the .js I get this error Cannot find module '@bull-board/api/bullMQAdapter' or its corresponding type declarations.

@felixmosh
Copy link
Owner

Not sure what is the issue, but where is the usage of path?

@pedropmedina
Copy link
Author

I don't use 'path' anywhere in my code @felixmosh . The errors shows when calling this function createBullBoard. Here's a the full block

// Queues monitoring UI
const serverAdapter = new ExpressAdapter();
serverAdapter.setBasePath('/queues/monitor');
createBullBoard({
  queues: [
    new BullMQAdapter(netsuiteQueueSync),
    new BullMQAdapter(netsuiteQueueCore),
  ],
  serverAdapter,
});

@felixmosh
Copy link
Owner

felixmosh commented May 15, 2023

Maybe it is related to this line, https://github.com/felixmosh/bull-board/blob/master/packages/api/src/index.ts#L18

Which makes several issues... I need to think how to solve it.

Do you have any suggestion?

related #444

@pedropmedina
Copy link
Author

pedropmedina commented May 15, 2023

hmm, I'll try to take a look. For a moment I thought the problem was my dev server, but the issue also show when running directly with node. It builds fine, it just comes up at runtime. I'm surprise nobody else has experienced this issue.

@pedropmedina
Copy link
Author

Hey @felixmosh, can you explain what the purpose of that line there is? Which path are you trying to resolve and why?

@felixmosh
Copy link
Owner

It is the path for static ui files.
It uses eval in order to allow bundling of the server code.

@pedropmedina
Copy link
Author

I see. You want to place those .css, .js, and assets at the same level as the UI package e.g node_modules/@bull-board/ui/dist/static? If so, can't you just hard code this location relative to the lib instead of doing so dynamically @felixmosh ?

@felixmosh
Copy link
Owner

It was relative, and we had some bug related to it... :)

I think that a better solution would be to allow users to provide that value for cases that default resolving is not working out of the box.

@pedropmedina
Copy link
Author

Yeah, that's what I was getting to. In such cases it's better to have the users provide the patch explicitly.

@felixmosh
Copy link
Owner

Can you try v5.2.0 which allows you to pass the uiBasePath?

createBullBoard({
    queues: [new BullMQAdapter(exampleBullMq)],
    serverAdapter,
    options: { uiBasePath: 'YOUR_PATH_TO_@bull-board/ui' } // <--------
  });

@pedropmedina
Copy link
Author

Hey @felixmosh that seems to do trick. Thanks a lot!

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