我正在试验Typescript,并尝试在TypeScript中使用EditorJS。到目前为止,我使用npm i @editorjs/editorjs为我的项目下载并安装了EditorJS。
然后,我尝试使用下面的代码行在我的项目中使用EditorJS:
import EditorJS from '@editorjs/editorjs';但是,构建失败,并显示以下消息:
Cannot find type definition file for 'data-formats'和
Cannot find module '@editorjs/editorjs'文件夹module_modules/@editorjs确实存在于我的项目中,所以我不知道问题出在哪里。
我希望有人能给我指明正确的方向
下面是我的项目结构的概述:
-/node_modules/
-- /@editorjs
-- /editorjs
-/src/
-- /@types/
-- Main.ts
- package.json我已经省略了所有其他与editorjs无关的文件夹
我的tsconfig.json如下:
{
"compilerOptions": {
"module": "es6",
"target": "ES2017",
"removeComments": true,
"preserveConstEnums": true,
"outDir": "./build",
"sourceRoot": "./src/",
"rootDir": "./src/",
"sourceMap": true,
"baseUrl": "./",
"typeRoots": [
"./node_modules/@types",
"./src/@types/",
"./node_modules/@editorjs/editorjs/types"
]
}
}在packakge.json中,我添加了以下依赖项:
"@editorjs/editorjs": "^2.17.0",提前谢谢。
发布于 2020-04-03 19:52:27
检查tsc配置。您似乎正在使用src/@types中的类型,并且包含了node_modules文件夹
发布于 2020-04-20 20:58:32
在导入语句中键入EditorJS应为CamelCase。
变化
import EditorJS from '@editorjs/editorjs';至
import **EditorJs from '@editorjs/editorjs';https://stackoverflow.com/questions/60918607
复制相似问题