Skip to main content
A MODULE_NOT_FOUND error means your application tried to import or require a library that isn’t installed in its runtime environment. This is one of the most common errors developers encounter when moving from local development to a hosted platform, because packages you installed globally on your machine or inside a local node_modules folder aren’t automatically available on Virtus Cloud. The platform installs dependencies fresh from your dependency manifest on every deployment — if a package isn’t declared there, it won’t be installed.

When Does It Occur?

This error appears in your application logs at startup or the first time the missing module is imported:
Error: Cannot find module 'discord.js'
Require stack:
- /application/index.js

Why Does It Occur?

Virtus Cloud builds a clean container for your application on each deployment. Packages that aren’t listed in your dependency file are never installed into that container — even if they were present in a previous deployment or in a node_modules folder you uploaded. Common causes include:
  • You installed a package locally (e.g., npm install discord.js) but never saved it to package.json.
  • Your package.json or requirements.txt exists but doesn’t include the missing package.
  • The dependency file was accidentally excluded from your upload.
  • The package name or version in the dependency file is misspelled or invalid.

How to Fix It

Open your package.json file and add the missing package to the dependencies section. Specify the exact version you need or use a version range:
package.json
{
  "name": "my-app",
  "version": "1.0.0",
  "main": "index.js",
  "dependencies": {
    "discord.js": "^14.14.1",
    "dotenv": "^16.4.5"
  }
}
1

Identify all missing packages

Read the error message carefully. Each Cannot find module 'X' entry tells you exactly which package is missing. Repeat the following steps for every missing package.
2

Add the package to dependencies

Open package.json and add the package name and version under "dependencies". If you’re unsure of the correct version, check the package’s page on npmjs.com and use the latest stable version.
3

Save and redeploy

Save package.json and redeploy your application. Virtus Cloud runs npm install automatically, which installs all listed packages into the container.
You can also create a package.json from scratch by running npm init -y locally, then installing your packages with npm install <package-name> — this automatically adds them to dependencies.

Verifying the Fix

After redeploying, open the Logs panel in the Virtus Cloud dashboard and watch the startup output. You should see the package manager install your dependencies without errors, followed by your application starting normally. If you still see a MODULE_NOT_FOUND error, double-check that:
  • The package name in your dependency file matches the exact name on npm or PyPI (names are case-sensitive).
  • The dependency file is saved in the root directory of your project, not inside a subdirectory.
  • You redeployed after saving the file — changes to package.json or requirements.txt don’t take effect until a new deployment runs.
If you continue to experience issues after following these steps, contact the Virtus Cloud support team.