Why am I receiving a missing module error when building my Node.js app on App Platform ?

Validated on 19 Apr 2023 • Last edited on 2 Jul 2024

App Platform throws this error when a module required to run the app is missing from the dependencies section of the app’s package.json file. The error usually looks like this:

Error: Cannot find module 'exampleModule'
[2022-11-01 00:59:32] Require stack:
[2022-11-01 00:59:32] - /workspace/server.js
[2022-11-01 00:59:32] at Function.Module._resolveFilename (node:internal/modules/cjs/loader:985:15)
[2022-11-01 00:59:32] at Function.Module._load (node:internal/modules/cjs/loader:833:27)
[2022-11-01 00:59:32] at Module.require
: 
:
(node:internal/modules/cjs/loader:868:12)
[2022-11-01 00:59:32] at Function.executeUserEntryPoint [as runMain] (node:internal/modules/run_main:81:12) {
[2022-11-01 00:59:32] code: 'MODULE_NOT_FOUND',

Sometimes developers mistakenly list the missing module in the devDependencies section of the package.json file instead of the dependencies section. The devDependencies section’s purpose is to list modules that are required to develop the app, such as linters and testing libraries. App Platform prunes the modules listed in the devDependencies section during the build process as they are not required to run the app. This process removes any modules that may have been erroneously listed in the devDependencies section.

To fix this problem, add the missing module to the dependencies section of your app’s package.json file. Alternatively, you can configure App Platform to skip the pruning process during deployment by setting one of the following environment variables:

  • For npm: NPM_CONFIG_PRODUCTION=false
  • For Yarn: YARN_PRODUCTION=false
Why am I getting an error when trying to forward DigitalOcean Functions to Managed OpenSearch?

Functions does not support forwarding to Managed OpenSearch.

My container-based app fails to deploy without logs or error codes.

Troubleshoot by making sure the Dockerfile and its commands build on Linux AMD64 and other steps.

How do I generate my app's SSL certificate?

App Platform automatically generates and issues the SSL certificate during the configuration.

We can't find any results for your search.

Try using different keywords or simplifying your search terms.