Name:
interface
Value:
Amplify has re-imagined the way frontend developers build fullstack applications. Develop and deploy without the hassle.

Page updated Dec 12, 2024

Troubleshoot "Cannot find module $amplify/env/<function-name>"

When deploying a Amplify Gen 2 app, you may encounter the error message Cannot find module $amplify/env/<function-name> in your frontend build on Amplify Console. This error occurs when your framework tsconfig.json configuration picks up the amplify directory and tries to resolve it as a module. This module is a placeholder for environment variables that are injected at build time by Amplify. To resolve this error, you will need to include the resource.ts files in your tsconfig.app.json file.

For example, if you have a function resource dependent on the data resource, you will need to include both the resource.ts files in your tsconfig.app.json file.

tsconfig.app.json
{
"include": [
"amplify/data/resource.ts",
"amplify/function/api-function/resource.ts",
]
}