Issue
Getting Cannot find module '' or its corresponding type declarations.
when importing in Next.js project.
This happens on every single import. Preview
Yarn version : 3.1.0-rc.2
Next version: 11.1.2
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",
"experimentalDecorators": true,
"resolveJsonModule": true,
"isolatedModules": true,
"importHelpers": true,
"jsx": "preserve",
// "baseUrl": "src"
},
"include": [
"next-env.d.ts",
"**/*.ts",
"**/*.tsx"
],
"exclude": [
"node_modules"
],
}
Solution
If you're using yarn 3, then you need to follow those steps to set up your VSCode:
- Run
yarn dlx @yarnpkg/sdks vscode
- Open any
TypeScript
file - Press
ctrl+shift+p
- Choose "Select TypeScript Version"
- Pick "Use Workspace Version"
Read here for other editors
Answered By - Cuong Vu
0 comments:
Post a Comment
Note: Only a member of this blog may post a comment.