NewSchokr 13 is here. A whole new UI, seven locations, snapshots and more. Read more →

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

MessageMeaning
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

  1. Check the package is in dependencies in package.json, not only installed on your own machine. Install it locally with npm install express so package.json is updated, then upload the new package.json and lock file.
  2. If it is listed under devDependencies and the server installs with --omit=dev or --production, move it to dependencies.
  3. Delete any node_modules folder you uploaded from your computer and restart so dependencies install fresh on the server.
  4. 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: ./Utils and ./utils are 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 is src/index.js, not index.js.
  • TypeScript: Node.js cannot run your .ts source unless you build it or use a loader. See TypeScript apps.

Python: missing package

  1. Add the package to requirements.txt. Note the install name can differ from the import name:
Importrequirements.txt
import discorddiscord.py
import dotenvpython-dotenv
import telegrampython-telegram-bot
import yamlPyYAML
import PILPillow
import bs4beautifulsoup4
  1. Restart and confirm pip installed it in the console.
  2. 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:app looks for app.py in 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__.py file to be safe.

Still stuck?

Paste the full error plus your file layout from the file manager in the Schokr Discord.