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: Cannot find package 'file-type' #1046

Open
Default-01 opened this issue Apr 2, 2023 · 4 comments
Open

Error: Cannot find package 'file-type' #1046

Default-01 opened this issue Apr 2, 2023 · 4 comments
Labels

Comments

@Default-01
Copy link

What happened:
I get this error when I use some features in my Discord bot, I've spoken to staff from the Framework of Discord.js and they believe this has to do with incorrect importing.

Error [ERR_MODULE_NOT_FOUND]: Cannot find package 'file-type' imported from C:\Users\Nando\Downloads\AdvancedTicketBot1.1\node_modules\@discordjs\rest\dist\index.js
Did you mean to import file-type/index.js?
    at new NodeError (node:internal/errors:372:5)
    at packageResolve (node:internal/modules/esm/resolve:954:9)
    at moduleResolve (node:internal/modules/esm/resolve:1003:20)
    at defaultResolve (node:internal/modules/esm/resolve:1218:11)
    at ESMLoader.resolve (node:internal/modules/esm/loader:580:30)
    at ESMLoader.getModuleJob (node:internal/modules/esm/loader:294:18)
    at ESMLoader.import (node:internal/modules/esm/loader:380:22)
    at importModuleDynamically (node:internal/modules/cjs/loader:1043:29)
    at importModuleDynamicallyWrapper (node:internal/vm/module:437:21)
    at importModuleDynamically (node:vm:381:46) {
  code: 'ERR_MODULE_NOT_FOUND'
} Unhandled Rejection

What you expected to happen:
To not show this error and import properly.

How to reproduce it (as minimally and precisely as possible):
setup a discord bot with discord.js V14 and create an attachment file.

Anything else we need to know?:
no

Environment:

  • Platform(OS/Version): Windows 10/11
  • Host Node Version: V16
  • Target Node Version: V16
  • Nexe version: 4.0.0-rc.1
  • Python Version:
@Default-01 Default-01 added the bug label Apr 2, 2023
@Default-01
Copy link
Author

any help?

@SalSevenSix
Copy link

SalSevenSix commented Jun 17, 2023

I hit this problem too. v13 is fine but v14 crashes with this error when trying to send a message with a file attachment.
Someone reported the same issue on discord.js : discordjs/discord.js#9508
They are using vercel/pkg which looks like it creates an exe package same as nexe
They closed the issue blaming vercel/pkg ... so who will investigate and fix this?

@JustSxm
Copy link

JustSxm commented Jun 17, 2023

I hit this problem too. v13 is fine but v14 crashes with this error when trying to send a message with a file attachment. Someone reported the same issue on discord.js : discordjs/discord.js#9508 They are using vercel/pkg which looks like it creates an exe package same as nexe They closed the issue blaming vercel/pkg ... so who will investigate and fix this?

If you're saying it works in v13, but not in v14, then perhaps thats the thing I didn't know which would make them actually investigate the bug now that v14 is known to be the issue here.

I would assume it would be a problem with how they build their library over how nexe handled the bundling of common js files.

@SalSevenSix
Copy link

I investigated today and it seems the issue is that discord.js v14 is using ESM modules. Both nexe and vercel/pkg don't support ESM...
#815
vercel/pkg#1291

So your options are to use v13 or ... be reckless and irresponsible like me and hack the @discordjs\rest\dist\index.js file so it doesn't import the file-type package.

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

No branches or pull requests

3 participants