Introduction
While developing an app with TypeScript, I received the error:
Cannot find module 'markdown-it' or its corresponding type declarations
This article briefly summarizes how to resolve this issue.
Solution
Cause
Because markdown-it is a JavaScript library, it did not include the type definition file (.d.ts) required by TypeScript.
In other words, the error occurred because markdown-it is a JavaScript library and does not contain type definitions.
Solution (This is all you need)
Install the type definition package.
tsx`
npm install -D @types/markdown-it
This will allow TypeScript to recognize type information, and the error will be resolved immediately.
Summary
The cause of the error was not the implementation, but simply a lack of type definitions for TypeScript. When using JavaScript libraries with TypeScript, type definitions may not be included.
Top comments (0)