Fix MODULE_NOT_FOUND and ModuleNotFoundError
Fix Cannot find module (MODULE_NOT_FOUND) in Node.js and Bun and ModuleNotFoundError in Python for apps running on Schokr.
Updated · 2 min read
These errors mean the runtime cannot find a file or package your code imports. Either the package is not installed on the server, or the path to your own file is wrong. The exact message tells you which.
Read the message first
| Message | Meaning |
|---|---|
Cannot find module 'express' | Package missing |
Cannot find module './utils' or '/home/.../index.js' | Your own file missing, or wrong path or case |
Cannot find package 'hono' imported from ... | ESM import of a missing package |
ModuleNotFoundError: No module named 'flask' | Python package missing |
ModuleNotFoundError: No module named 'app' | Your own module not found from the working directory |
Node.js and Bun: missing package
- Check the package is in
dependenciesinpackage.json, not only installed on your own machine. Install it locally withnpm install expresssopackage.jsonis updated, then upload the newpackage.jsonand lock file. - If it is listed under
devDependenciesand the server installs with--omit=devor--production, move it todependencies. - Delete any
node_modulesfolder you uploaded from your computer and restart so dependencies install fresh on the server. - Watch the console during startup to confirm the install ran without errors. See installing dependencies.
Node.js and Bun: your own file
- Linux paths are case-sensitive:
./Utilsand./utilsare different. - In ESM (
"type": "module"), relative imports need the file extension:import x from './utils.js'. - Check the main file in your server's Startup settings matches the real file name and folder. If your code lives in
src/, the main file issrc/index.js, notindex.js. - TypeScript: Node.js cannot run your
.tssource unless you build it or use a loader. See TypeScript apps.
Python: missing package
- Add the package to
requirements.txt. Note the install name can differ from the import name:
| Import | requirements.txt |
|---|---|
import discord | discord.py |
import dotenv | python-dotenv |
import telegram | python-telegram-bot |
import yaml | PyYAML |
import PIL | Pillow |
import bs4 | beautifulsoup4 |
- Restart and confirm pip installed it in the console.
- If pip fails with "No matching distribution", the package version does not support the server's Python version. Try a different version.
Python: your own module
- Run your app from the folder that contains the package.
gunicorn app:applooks forapp.pyin the working directory. - For a project in a subfolder, use
gunicorn --chdir src app:app, or set the startup file path accordingly. - Folders imported as packages should contain an
__init__.pyfile to be safe.
Still stuck?
Paste the full error plus your file layout from the file manager in the Schokr Discord.