javascript - 在 TypeScript 中使用 EditorJS 时遇到问题
问题描述
我正在尝试使用 TypeScript 并尝试将 EditorJS 与 Typescript 一起使用。到目前为止,我为我的项目下载并安装了 EditorJS,npm i @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",
提前致谢。
解决方案
在导入语句 EditorJS 中的类型应该是 CamelCase。
改变
import EditorJS from '@editorjs/editorjs';
至
import **EditorJs from '@editorjs/editorjs';
推荐阅读
- elasticsearch - 在弹性搜索中进行标记时从文本中删除符号
- php - 向 WP Genesis 菜单添加类,不包括其他菜单
- java - 如何在 3d 场景上制作这样的侧边栏,使其不隐藏场景?
- elasticsearch - Range @Timestamp 没有在 Watcher Kibana 中给出结果
- bash - Bash while 循环直到 EOF
- javascript - 如何知道 puppeteer 使用的 Chromium 路径?
- vue.js - 在 vuetify 中更改网格中的列宽
- android - 如何从 buildSrc 中的自定义 Gradle 插件访问 Android 的“dynamicFeatures”属性
- arrays - 增加或插入 mongo 嵌套数组值
- django - 在 Django 数据库查询中计算百分比