The question is VSCode related.
I have project with pnpm monorepo.
// root
package.json
apps
nextjsApp
tsconfig.json
package.json
packages
uiLib
tsconfig.json
package.json
The project is compiled and works run-time BUT I have problems in VSCode.
PROBLEMS
-
In VSCode in nextjsApp all imports outside of the project
cannot be found. For example from “uiLib” project. -
In VsCode in nextjsApp all imports from node_modules cannot
be found. For example from “next” -
Bebugging nextjsApp not working.
Here is the tsconfig.json of nextjsApp:
{
"compilerOptions": {
"baseUrl": "./",
"paths": {
"@components": ["src/components"],
"@components/*": ["src/components/*"],
...
},
"target": "esnext",
"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,
"sourceMap": true
},
"include": [
"next-env.d.ts",
"**/*.ts",
"**/*.tsx",
"next.config.js",
...
],
"exclude": [
"node_modules",
".github",
".next",
"dist",
".husky",
".yarn",
".pnpm"
]
}
And here is my VSCode launch settings that I use in all nextjs projects for debugging
{
"version": "0.2.0",
"configurations": [
{
"name": "Next.js: debug server-side",
"type": "node-terminal",
"request": "launch",
"command": "npm run dev"
},
{
"name": "Next.js: debug client-side",
"type": "chrome",
"request": "launch",
"url": "http://localhost:3000"
},
{
"name": "Next.js: debug full stack",
"type": "node-terminal",
"request": "launch",
"command": "npm run dev",
"serverReadyAction": {
"pattern": "started server on .+, url: (https?://.+)",
"uriFormat": "%s",
"action": "debugWithChrome"
}
}
]
}