discordx-ts / discordx

🤖 Create a discord bot with TypeScript and Decorators!
https://discordx.js.org
Apache License 2.0
583 stars 50 forks source link

[Bug]: SyntaxError: Named export 'glob' not found. #1016

Closed SachsenspieltCoding closed 1 month ago

SachsenspieltCoding commented 1 month ago

What happened?

When our discord bot (using discordx) is started in a docker environment, it fails to start, due to the "glob" import inside @discordx/importer

see also https://github.com/nplay-team/moderation-bot/issues/8

Reproduction

https://github.com/nplay-team/moderation-bot/tree/ff245bd96934940c96d883df2d1e4abce279f1bb

Package

@discordx/importer

Version

Stable

Relevant log output

nplay-moderation-bot       | file:///usr/src/app/node_modules/@discordx/importer/dist/index.mjs:2
nplay-moderation-bot       | import { glob } from "glob";
nplay-moderation-bot       |          ^^^^
nplay-moderation-bot       | SyntaxError: Named export 'glob' not found. The requested module 'glob' is a CommonJS module, which may not support all module.exports as named exports.
nplay-moderation-bot       | CommonJS modules can always be imported via the default export, for example using:
nplay-moderation-bot       | 
nplay-moderation-bot       | import pkg from 'glob';
nplay-moderation-bot       | const { glob } = pkg;
nplay-moderation-bot       | 
nplay-moderation-bot       |     at ModuleJob._instantiate (node:internal/modules/esm/module_job:134:21)
nplay-moderation-bot       |     at async ModuleJob.run (node:internal/modules/esm/module_job:217:5)
nplay-moderation-bot       |     at async ModuleLoader.import (node:internal/modules/esm/loader:316:24)
nplay-moderation-bot       |     at async asyncRunEntryPointWithESMLoader (node:internal/modules/run_main:123:5)
nplay-moderation-bot       | 
nplay-moderation-bot       | Node.js v20.14.0

Code of Conduct

samarmeena commented 1 month ago

Hi, can you please update reproduction repo with one of our templates. This package is released months ago, I suspect what could be the cause. I want to see changes based on our templates, if no changes required in template then let me know.

SachsenspieltCoding commented 1 month ago

It would be more helpful to just say what the problem might be rather than asking people to follow some template. I can understand if you don't want to familiarize yourself with other people's codebases, but I didn't ask for a template. Sorry for that.

We have already been able to solve the problem with our own importer, but thanks for the quick reply anyway.

samarmeena commented 1 month ago

Glob is a esm module, make sure to install latest version. And your project is configured to use esm.

samarmeena commented 1 month ago

I have tested and was unable to verify the issue. I am closing this ticket. If you have any follow-up questions, please let me know or create a ticket in our discordx server. Thank you.