So this is lately one of the most popular issues in discord.js community. Appears after updating to d.js v13.7.0 and higher. While it works perfectly on a PC or etc., it fails to run on Heroku hosting with the following message:
Error: Cannot find module '../Modal'
This is clear that the issue is on Heroku's side, because Modal
file can be found in discord.js dependency folder in node_modules
.
I have NodeJS v18.3.0, have tried reinstalling discord.js with multiple methods, nothing helped.
I wasn't able to find any solutions to the problem, have anyone over here found the solution?
CodePudding user response:
Well personally i would recommend for you to add a .gitignore
file.
As the file will probably help in deploying the bot itself.
Now as for the cannot find ../Modal means either you defined a package to that exact path or you defined it wrongly. If you want to define something In node modules you could do ./node_modules/files/to/somewhere/new
<---//If the node_modules is in another folder add ../
and so on, and it should automatically pop up in your screen if your using vs.
As for the Discord.js version, it is true what you say about the Heroku error, you could try using an old version like v13.1.0 and so on to probably fix the problem, but just for your information Discord.jsv14 is coming out soon so you should start rewriting your bot when possible. I hope something helped you from above.
.gitignore Instructions
- Create a
.gitignore
file. - Inside the file, on the first line input
node_modules
or./node_modules
and so on if in a subdirectory - Clear cache from data that contains the folder
node_modules
- Make sure to have a
dotenv
file to execute your secrets
CodePudding user response:
Im pretty sure that you didn't create a file called .gitignore
because it shows that your problem is on the folders '../Modal'
, Before deploying it to heroku, you should ignore
the 2 files
on your project.
- node_modules
- .env (if you have)
To remove these 2 on your deploying, create a file on your main folder named .gitignore
and right down the following:
node_modules
.env