2

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?

8
  • what command are you running to build the project? Commented Apr 22, 2022 at 18:36
  • @davidvarela_us I am running yarn build Commented Apr 22, 2022 at 18:36
  • 1
    And what does your package.json include for that command? Most likely either not build, or missing dependencies. Commented Apr 22, 2022 at 18:37
  • You get the same error if you run npx next build directly? Commented Apr 22, 2022 at 18:42
  • @Lissy93 yeah, getting the same error Commented Apr 22, 2022 at 18:43

2 Answers 2

3

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.

Sign up to request clarification or add additional context in comments.

Comments

0

Include "types" in your "compilerOptions" ...

{
  "compilerOptions": {
    "types": [
      // ... your other types
      "node"
    ],
  },
}

you can read more from this link :https://www.typescriptlang.org/tsconfig/#types

Comments

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge you have read our privacy policy.

Start asking to get answers

Find the answer to your question by asking.

Ask question

Explore related questions

See similar questions with these tags.