I’m experiencing an issue with my Next.js project involving TypeScript. I get the following error in my layout.tsx file:
I tried reinstalling all the project dependencies by deleting the node_modules folder and the package-lock.json file, and then running npm install again. I expected this to resolve any potential issues with outdated or corrupted packages that might be causing the TypeScript error.
However, despite these efforts, the error Cannot find name ‘html’ TS2304 still persists in the layout.tsx file. I was expecting the reinstallation of packages to either resolve the issue or provide a clearer indication of what might be causing it.
Here is my tsconfig.json
enter image description here
Do you add tsconfig.json
file to the project? If not, create one with the following config option like:
{
"compilerOptions": {
"jsx": "preserve",
}
This should resolve the TS issue.
3