I've encountered an issue while working on my TypeScript project with Next.js. Initially, I named my config file as next.config.js
, but it resulted in a warning in the tsconfig.json
file stating "next.config.ts not found," leading to a warning sign on the {}
.
Upon changing the extension to .ts
, I faced another error when trying to start the project:
"Error: Configuring Next.js via 'next.config.ts' is not supported. Please replace the file with 'next.config.js'."
This dilemma has left me confused about what steps to take next.
Here's a snippet of my tsconfig.json configuration:
{
"compilerOptions": {
"target": "es6",
"lib": ["dom", "dom.iterable", "esnext"],
"allowJs": true,
"baseUrl": ".",
"paths": {
"@/*": ["src/*"]
},
"skipLibCheck": true,
"strict": true,
"forceConsistentCasingInFileNames": true,
"noEmit": true,
"esModuleInterop": true,
"module": "esnext",
"moduleResolution": "node",
"resolveJsonModule": true,
"isolatedModules": true,
"sourceMap": true,
"removeComments": true,
"jsx": "preserve"
},
"include": ["next-env.d.ts", "**/*.ts", "**/*.tsx"],
"exclude": ["node_modules"]
}
Below is the content of my next.config.ts file:
const path = require("path");
const Dotenv = require("dotenv-webpack");
module.exports = {
env: {
AUTH0_NAMESPACE: process.env.AUTH0_NAMESPACE,
BASE_URL: process.env.BASE_URL,
},
};