---
title: "Troubleshoot \"Cannot find module $amplify/env/<function-name>\""
section: "build-a-backend/troubleshooting"
platforms: ["angular", "javascript", "flutter", "nextjs", "react", "react-native", "vue"]
gen: 2
last-updated: "2025-11-03T15:11:39.000Z"
url: "https://docs.amplify.aws/react/build-a-backend/troubleshooting/cannot-find-module-amplify-env/"
---

<!-- Platform: javascript,  react-native, angular, flutter, nextjs, react -->
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 need to exclude the `amplify` directory.

To exclude the `amplify` directory in your `tsconfig.json`, add the following lines to the `exclude` section:

```ts title='tsconfig.json'
{
  "exclude": ["amplify/**/*"]
}
```

Amplify will perform type-checking on sandbox and pipeline-deploy using the tsconfig local to the Amplify backend `amplify/tsconfig.json`. If you'd like to extend your base configuration you can add it to the localized tsconfig.

Alternatively, if you work within a monorepo you can move your backend to its own package and export the Schema and outputs for ease of sharing with your other apps. For example, in your backend package's `package.json`

```json title='package.json'
{
  "name": "my-backend",
  "private": true,
  "exports": {
    "./schema": "./amplify/data/resource.ts",
    "./outputs": "./amplify_outputs.json"
  }
}
```
<!-- /Platform -->

<!-- Platform: vue -->
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.

```ts title='tsconfig.app.json'
{
  "include": [
    "amplify/data/resource.ts",
    "amplify/function/api-function/resource.ts",
  ]
}
```
<!-- /Platform -->
