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. Python: add it to requirements.txt and restart (pip install runs on every start). Node.js: add it to package.json, then delete the node_modules folder (and package-lock.json, if you uploaded one) in the dashboard's file manager and restart, so npm install runs again. Restarting alone does not reinstall Node.js packages.
Node.js — package.json:
{
"dependencies": {
"discord.js": "14.14.1"
}
}Python — requirements.txt:
discord.pyThe platform installs dependencies on startup when the node_modules folder does not exist (Node.js), or on every startup (Python). A commit extracts your zip over the existing files and does not remove node_modules, so on Node.js always delete that folder before restarting.
Quick checklist
- Is the library spelled exactly as published on npm/PyPI?
- Is it listed under
dependencies(not onlydevDependencies)? - Node.js: did you delete
node_modulesbefore restarting? Python: did you restart after editing the file?
Related
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: 10/04/2026
Thank you!
