LoaderStrategy: promises.opendir is being broken if using with @vercel/pkg library

Hey There! I'm trying to build the bot into signle executable but there is an issue When trying to load the listeners, commands etc It fails because of
node:internal/process/promises:288
triggerUncaughtException(err, true /* fromPromise */);
^

[Error: ENOENT: no such file or directory, opendir 'C:\snapshot\VaultCord.bot\dist\src\commands'] {
errno: -4058,
code: 'ENOENT',
syscall: 'opendir',
path: 'C:\\snapshot\\VaultCord.bot\\dist\\src\\commands'
}

Node.js v18.5.0
node:internal/process/promises:288
triggerUncaughtException(err, true /* fromPromise */);
^

[Error: ENOENT: no such file or directory, opendir 'C:\snapshot\VaultCord.bot\dist\src\commands'] {
errno: -4058,
code: 'ENOENT',
syscall: 'opendir',
path: 'C:\\snapshot\\VaultCord.bot\\dist\\src\\commands'
}

Node.js v18.5.0
From what I see PKG has this issue for a long time https://github.com/vercel/pkg/issues/1505 and it's not fixed https://github.com/sapphiredev/pieces/blob/main/src/lib/strategies/LoaderStrategy.ts#L128 Cause of problem is this line const dir = await opendir(path); promises.readdir work fine What should I do in this situation?
GitHub
fs.stat not working · Issue #1505 · vercel/pkg
What version of pkg are you using? 5.5.2 What version of Node.js are you using? 16.13.1 What operating system are you using? windows 10 What CPU architecture are you using? intel i7 What Node versi...
GitHub
pieces/src/lib/strategies/LoaderStrategy.ts at main · sapphiredev/p...
Piece loader for @sapphire/framework. Contribute to sapphiredev/pieces development by creating an account on GitHub.
Solution:
You can change all your pieces to virtual pieces so no more filesystem calls are performed: https://www.sapphirejs.dev/docs/Guide/additional-information/registering-virtual-pieces
Sapphire Framework
Registering and loading virtual pieces | Sapphire
Virtual pieces differ from normal pieces in that they are not loaded from the file system. Instead, they are registered
Jump to solution
3 Replies
Solution
Favna
Favna12mo ago
You can change all your pieces to virtual pieces so no more filesystem calls are performed: https://www.sapphirejs.dev/docs/Guide/additional-information/registering-virtual-pieces
Sapphire Framework
Registering and loading virtual pieces | Sapphire
Virtual pieces differ from normal pieces in that they are not loaded from the file system. Instead, they are registered
Saitama
SaitamaOP12mo ago
well yea it's a solution Thought of it But thought there'd be another way
Favna
Favna12mo ago
If you're using @vercel/pkg then I assume you're deploying to Vercel, which is gonna give issues with fs sooner or later anyway. so it's a good thing to use virtual pieces either way
Want results from more Discord servers?
Add your server