t3-env is giving error module is not defined in ES module scope

i am trying to add t3-env in my project and it is giving me error
- error Failed to load next.config.mjs, see more info here https://nextjs.org/docs/messages/next-config-error

> Build error occurred
ReferenceError: module is not defined in ES module scope
at file:///C:/Users/new/Documents/resume-builder/next.config.mjs:5:1
- error Failed to load next.config.mjs, see more info here https://nextjs.org/docs/messages/next-config-error

> Build error occurred
ReferenceError: module is not defined in ES module scope
at file:///C:/Users/new/Documents/resume-builder/next.config.mjs:5:1
tsconfig.json
{
"compilerOptions": {
"target": "es6",
"lib": ["dom", "dom.iterable", "esnext"],
"allowJs": true,
"skipLibCheck": true,
"strict": true,
"forceConsistentCasingInFileNames": true,
"noEmit": true,
"esModuleInterop": true,
"module": "esnext",
"moduleResolution": "node",
"resolveJsonModule": true,
"isolatedModules": true,
"noUncheckedIndexedAccess": true,
"jsx": "preserve",
"incremental": true,
"plugins": [
{
"name": "next"
}
],
"paths": {
"@/*": ["./*"]
}
},
"include": [
"next-env.d.ts",
"**/*.ts",
"**/*.tsx",
".next/types/**/*.ts",
"tsconfig.json",
"**/*.mjs"
],
"exclude": ["node_modules"]
}
{
"compilerOptions": {
"target": "es6",
"lib": ["dom", "dom.iterable", "esnext"],
"allowJs": true,
"skipLibCheck": true,
"strict": true,
"forceConsistentCasingInFileNames": true,
"noEmit": true,
"esModuleInterop": true,
"module": "esnext",
"moduleResolution": "node",
"resolveJsonModule": true,
"isolatedModules": true,
"noUncheckedIndexedAccess": true,
"jsx": "preserve",
"incremental": true,
"plugins": [
{
"name": "next"
}
],
"paths": {
"@/*": ["./*"]
}
},
"include": [
"next-env.d.ts",
"**/*.ts",
"**/*.tsx",
".next/types/**/*.ts",
"tsconfig.json",
"**/*.mjs"
],
"exclude": ["node_modules"]
}
next.config.mjs
await import('./src/env.mjs');
/** @type {import('next').NextConfig} */
const nextConfig = {};
module.exports = nextConfig;
await import('./src/env.mjs');
/** @type {import('next').NextConfig} */
const nextConfig = {};
module.exports = nextConfig;
please help me with this i am unable to find how to resolve this error
3 Replies
pradeep
pradeepOP17mo ago
package.json
json
{
"name": "resume-builder",
"version": "0.1.0",
"private": true,
"scripts": {
"dev": "next dev -p 3008",
"build": "next build ",
"start": "next start",
"lint": "next lint",
"prettier": "prettier --write",
"drizzle:generate": "drizzle-kit generate:mysql",
"drizzle:push": "node -r esbuild-register lib/db/migrate.ts",
"drizzle:studio": "drizzle-kit studio --port 3007 --verbose"
},
"dependencies": {
"@planetscale/database": "^1.10.0",
"@radix-ui/react-slot": "^1.0.2",
"@t3-oss/env-nextjs": "^0.6.0",
"@types/node": "20.5.0",
"@types/react": "18.2.20",
"@types/react-dom": "18.2.7",
"autoprefixer": "10.4.15",
"class-variance-authority": "^0.7.0",
"clsx": "^2.0.0",
"drizzle-orm": "^0.28.2",
"eslint": "8.47.0",
"eslint-config-next": "13.4.16",
"lucide-react": "^0.268.0",
"next": "13.4.16",
"next-auth": "^4.23.1",
"nodemailer": "^6.9.4",
"postcss": "8.4.28",
"prettier": "^3.0.2",
"react": "18.2.0",
"react-dom": "18.2.0",
"tailwind-merge": "^1.14.0",
"tailwindcss": "3.3.3",
"tailwindcss-animate": "^1.0.6",
"typescript": "5.1.6",
"undici": "^5.23.0",
"zod": "^3.22.1",
"zustand": "^4.4.1"
},
"engines": {
"npm": "*",
"yarn": "use-npm",
"pnpm": "use-npm"
},
"devDependencies": {
"@types/nodemailer": "^6.4.9",
"drizzle-kit": "^0.19.12"
}
}
json
{
"name": "resume-builder",
"version": "0.1.0",
"private": true,
"scripts": {
"dev": "next dev -p 3008",
"build": "next build ",
"start": "next start",
"lint": "next lint",
"prettier": "prettier --write",
"drizzle:generate": "drizzle-kit generate:mysql",
"drizzle:push": "node -r esbuild-register lib/db/migrate.ts",
"drizzle:studio": "drizzle-kit studio --port 3007 --verbose"
},
"dependencies": {
"@planetscale/database": "^1.10.0",
"@radix-ui/react-slot": "^1.0.2",
"@t3-oss/env-nextjs": "^0.6.0",
"@types/node": "20.5.0",
"@types/react": "18.2.20",
"@types/react-dom": "18.2.7",
"autoprefixer": "10.4.15",
"class-variance-authority": "^0.7.0",
"clsx": "^2.0.0",
"drizzle-orm": "^0.28.2",
"eslint": "8.47.0",
"eslint-config-next": "13.4.16",
"lucide-react": "^0.268.0",
"next": "13.4.16",
"next-auth": "^4.23.1",
"nodemailer": "^6.9.4",
"postcss": "8.4.28",
"prettier": "^3.0.2",
"react": "18.2.0",
"react-dom": "18.2.0",
"tailwind-merge": "^1.14.0",
"tailwindcss": "3.3.3",
"tailwindcss-animate": "^1.0.6",
"typescript": "5.1.6",
"undici": "^5.23.0",
"zod": "^3.22.1",
"zustand": "^4.4.1"
},
"engines": {
"npm": "*",
"yarn": "use-npm",
"pnpm": "use-npm"
},
"devDependencies": {
"@types/nodemailer": "^6.4.9",
"drizzle-kit": "^0.19.12"
}
}
sean
sean17mo ago
What's your env.mjs? Oh, nevermind. Replace what you did in your Next config with this,
import "./src/env.mjs";

/** @type {import("next").NextConfig} */
const config = {
/** ... */
};

export default config;
import "./src/env.mjs";

/** @type {import("next").NextConfig} */
const config = {
/** ... */
};

export default config;
@pradeep9339
pradeep
pradeepOP17mo ago
thank you for help
Want results from more Discord servers?
Add your server