why does this not work in sapphire

index.js
const { util } = require("./utils");
const { container } = require("@sapphire/framework");

container.util = util;
const { util } = require("./utils");
const { container } = require("@sapphire/framework");

container.util = util;
basically I want to access ./utils using this.container.util
Solution:
That would be:
const util = require("./utils");
const util = require("./utils");
...
Jump to solution
14 Replies
Spinel
Spinel•16mo ago
When asking for help, make sure to provide as much detail as possible. What have you tried so far? Do you have stacktraces that you can show us? What are you trying to achieve? Try to answer these questions and others, so we do not have to ask for them afterwards.
❯ For a good guide on how to ask questions, see the instructions that StackOverflow gives. You should try to always follow these guidelines. ❯ For an excellent video that shows how not to ask technical questions is this, watch this YouTube video by LiveOverflow. ❯ Asking technical questions (Clarkson) ❯ How to ask questions the smart way (Raymond)
Lioness100
Lioness100•16mo ago
Specifically, what problem are you running into? @-Carlosđź‘‘
-Carlosđź‘‘
-Carlos👑•16mo ago
it returns undefined
Lioness100
Lioness100•16mo ago
what, where, when
-Carlosđź‘‘
-Carlos👑•16mo ago
evaled it using my eval cmd
Lioness100
Lioness100•16mo ago
Can you show your full index.js?
-Carlosđź‘‘
-Carlos👑•16mo ago
.
Lioness100
Lioness100•16mo ago
Can you show utils.js please? 🙂
-Carlosđź‘‘
-Carlos👑•16mo ago
it's pretty long but here's a small part of it .
Lioness100
Lioness100•16mo ago
It looks like you're not exporting anything called util Did you mean to use a default import?
Solution
Lioness100
Lioness100•16mo ago
That would be:
const util = require("./utils");
const util = require("./utils");
Lioness100
Lioness100•16mo ago
(removal of curly brackets)
-Carlosđź‘‘
-Carlos👑•16mo ago
didn't notice that, thanks
Lioness100
Lioness100•16mo ago
Np 🙂