t3-oss / t3-env

https://env.t3.gg
MIT License
2.67k stars 86 forks source link

Error while generating production build for the web application #205

Closed rajanchaudhari08 closed 6 months ago

rajanchaudhari08 commented 7 months ago
Error:

Cannot find module '@t3-oss/env-nextjs' or its corresponding type declarations. There are types at '/<repo-path>/node_modules/@t3-oss/env-nextjs/dist/index.d.ts', but this result could not be resolved under your current 'moduleResolution' setting.

env.js

    import { createEnv } from "@t3-oss/env-nextjs";
    import { z } from "zod";

tsconfig.json

    "lib": ["dom", "dom.iterable", "ES2022"],
    "noEmit": true,
    "module": "ESNext",
    "moduleResolution": "Node",
    "jsx": "preserve",
    "plugins": [{ "name": "next" }],
    "incremental": true,

package.json

"dependencies": {
    "@next/bundle-analyzer": "^14.1.1",
    "@prisma/client": "^5.10.2",
    "@t3-oss/env-nextjs": "^0.9.2",
    "@tanstack/react-query": "^4.36.1",
    "@trpc/client": "^10.45.1",
    "@trpc/next": "^10.45.1",
    "@trpc/react-query": "^10.45.1",
    "@trpc/server": "^10.45.1",
    "@vercel/analytics": "^1.2.2",
    "next": "^14.1.0",
    "react": "18.2.0",
    "react-dom": "18.2.0",
    "react-hook-form": "^7.50.1",
    "resend": "^3.2.0",
    "superjson": "^2.2.1",
    "zod": "^3.22.4"
  },
  "devDependencies": {
    "@types/eslint": "^8.56.2",
    "@types/node": "^20.11.20",
    "@types/react": "^18.2.57",
    "@types/react-dom": "^18.2.19",
    "@typescript-eslint/eslint-plugin": "^7.0.2",
    "@typescript-eslint/parser": "^7.0.2",
    "eslint": "^8.56.0",
    "eslint-config-next": "^14.1.0",
    "postcss": "^8.4.34",
    "prettier": "^3.2.5",
    "prettier-plugin-tailwindcss": "^0.5.11",
    "prisma": "^5.10.2",
    "tailwindcss": "^3.4.1",
    "typescript": "^5.3.3"
  },
JonasDoesThings commented 6 months ago

Changing "moduleResolution" from "node" to "Bundler" in my tsconfig fixed it. Check if your project allows for changing the value without problems.

https://www.totaltypescript.com/tsconfig-cheat-sheet also recommends using either "NodeNext" or "Bundler" depending on your project.

juliusmarminge commented 6 months ago

image