I am using next.js 13.4 where I am getting error on directly importing any module from node_modules.
This is not working:-
import Link from "next/link"
if I do this then its working:
import Link from "@/next/link" // or import Link from "../../../node_modules/next/link
I am having this issue with all the modules I import. Does anyone know what's the issue I even changed node version from 16 to 18.
I tried changing path from tsconfig.json but then it's working with @/next/link
not like next/link
. I also changed node.js version from 16 to 18
my 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": "bundler",
"resolveJsonModule": true,
"isolatedModules": true,
"jsx": "preserve",
"incremental": true,
"plugins": [
{
"name": "next"
}
],
"paths": {
"@/*": ["./src/*"]
}
},
"include": ["next-env.d.ts", "**/*.ts", "**/*.tsx", ".next/types/**/*.ts"],
"exclude": ["node_modules"]
}