I am constructing a website in the next 13 versions with TypeScript, using the src folder and app directory. When I execute `npm run dev`, everything functions correctly. However, upon building, I encounter this error...
./node_modules/next-auth/src/core/lib/assert.ts:134:27
Type error: Element implicitly has an 'any' type because expression of type 'string' can't be used to index type 'Adapter'.
No index signature with a parameter of type 'string' was found on type 'Adapter'.
132 | "useVerificationToken",
133 | "getUserByEmail",
> 134 | ].filter((method) => !adapter[method])
| ^
135 |
136 | if (missingMethods.length) {
137 | return new MissingAdapterMethods(
This suggests that the build process/typescript may be attempting to handle the node_modules directory.
tsconfig.json
{
"compilerOptions": {
"target": "es5",
"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,
"jsx": "preserve",
"incremental": true,
"plugins": [
{
"name": "next"
}
],
"baseUrl": ".",
"paths": {
"@/*": ["./src/**/*"]
},
"types": [],
},
"include": ["next-env.d.ts", "**/*.ts", "**/*.tsx", ".next/types/**/*.ts"],
"exclude": [
"node_modules",
"./node_modules",
"./node_modules/*",
"./node_modules/@types/node/index.d.ts"
]
}
package.json
{
"name": "next13-app",
"version": "0.1.0",
"private": true,
"scripts": {
"dev": "next dev",
"build": "next build",
"start": "next start",
"lint": "next lint"
},
"dependencies": {
<!-- list of dependencies -->
},
"devDependencies": {
<!-- list of development dependencies -->
}
}
Upon investigating the online resources for this issue, most recommended adding the "skipLibCheck": true
option in the tsconfig, which is already predefined. To delve deeper, some suggested adding exclusions, prompting me to add:
"./node_modules",
"./node_modules/*",
"./node_modules/@types/node/index.d.ts"
Here is my auth>[...nextauth]>route.ts file
import {prisma} from '../../../../lib/prisma'
import {PrismaAdapter} from "@next-auth/prisma-adapter";
import NextAuth from 'next-auth'
import type {NextAuthOptions} from 'next-auth'
import GithubProvider from 'next-auth/providers/github'
export const authOptions: NextAuthOptions = {
<!-- authentication options here -->
};
const handler = NextAuth(authOptions);
export {
handler as GET,
handler as POST,
}