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 receiving 520 status codes from my app?

Your app may have crashed while trying to receive an upload or return a response larger than it has been configured to manage.

Why am I receiving a forbidden error when making changes to my App Platform app?

Your team balance may be past due. Pay your balance to lift restrictions on actions you can take on the platform.

Why does my app not restart when it fails a health check?

If an app’s health check fails, the app currently does not restart. This is because App Platform does not currently support liveness probes. An app only automatically restarts if the app crashes or if its disk or RAM usage exceeds the its limits.

We can't find any results for your search.

Try using different keywords or simplifying your search terms.