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
How do I fix the error "Record is managed by an App on this account, and cannot be deleted"?

Use the app’s Settings tab to remove domains associated with App Platform apps.

Why do I get the error “JavaScript heap out of memory” during deployment?

Increase the heap memory by setting the environment variable NODE_OPTIONS=–max-old-space-size=4096.

How do I fix a "permission denied for schema public" error in my dev database?

Delete the existing dev database and create a new one. Then make sure that the app deployment completes successfully.

We can't find any results for your search.

Try using different keywords or simplifying your search terms.