Error: Cannot find package 'file-type'
Default-01 opened this issue · 4 comments
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:
any help?
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?
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.
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.