Articles on: Troubleshooting

MODULE_NOT_FOUND / Cannot find module: how to fix

What this error means


Your application is trying to use a library that isn't installed in the environment. Depending on the language, the message looks like:


# JavaScript / Node.js
Error: Cannot find module 'discord.js'

# Python
ModuleNotFoundError: No module named 'discord'


Why it happens


On Square Cloud, libraries are not installed by default — they have to be declared in your dependency file so the platform installs them during deploy. If a package is missing from that file (or was only installed locally on your computer), the app can't find it at runtime.


How to fix it


Add the missing library to your dependency file and restart the application so it reinstalls everything.


Node.js — package.json:


{
"dependencies": {
"discord.js": "14.14.1"
}
}


Python — requirements.txt:


discord.py


After updating the file, restart (or re-deploy) the application. The platform reads the dependency file and installs the listed packages.


Quick checklist


  • Is the library spelled exactly as published on npm/PyPI?
  • Is it listed under dependencies (not only devDependencies)?
  • Did you restart the app after editing the file?



If the dependency file itself can't be found, see INVALID_DEPENDENCY: dependency file not found on deploy. For native modules such as SQLite, see Could not locate the bindings file: how to fix the better-sqlite3 error.


Updated on: 06/13/2026

Was this article helpful?

Share your feedback

Cancel

Thank you!