I am trying to build nextjs project and getting this error:
Type error: Cannot find type definition file for 'build'. The file is in the program because: Entry point for implicit type library 'build'
how can I build without this error?
This is how package.json looks:
{ "name": "frontend", "version": "0.1.0", "private": true, "license": "fa", "scripts": { "dev": "next dev", "build": "next build", "start": "next start", "lint": "next lint" }, "dependencies": { "@ckeditor/ckeditor5-alignment": "^33.0.0", "@ckeditor/ckeditor5-build-classic": "^33.0.0", "@ckeditor/ckeditor5-code-block": "^33.0.0", "@ckeditor/ckeditor5-react": "^4.0.0", "@hookform/resolvers": "^2.8.8", "@types/": "ckeditor/ckeditor5-alignment", "axios": "^0.26.0", "dompurify": "^2.3.6", "highlight.js": "^11.5.0", "isomorphic-dompurify": "^0.18.0", "mobx": "^6.4.2", "mobx-react-lite": "^3.3.0", "next": "^12.1.5", "nextjs-progressbar": "^0.0.14", "react": "^18.0.0", "react-dom": "^18.0.0", "react-hook-form": "^7.27.1", "sass": "^1.49.9", "yup": "^0.32.11" }, "devDependencies": { "@types/node": "^17.0.25", "@types/react": "^18.0.6", "eslint": "8.10.0", "eslint-config-next": "12.1.0", "typescript": "^4.6.3" } }
I am trying to build using yarn build command
Why am I getting this error and how can I get rid of it?
Advertisement
Answer
The issue is caused by this line in your package.json
:
"@types/": "ckeditor/ckeditor5-alignment",
Looks like yarn add
gone wrong. Uninstall that, remove it from your package.json, and you should be good to go 🙂
This issue occurs when you have subdirectories of a typeRoots
directory (in this case node_modules/@types
) that do not contain index.d.ts
.
I agree, not a very clear error message. For more info, Microsoft/TypeScript #27956 discusses this same problem.