npm或cnpm install 安装tui-editor报错解决方案,亲测有效

Web前端 潘老师 2年前 (2022-05-15) 10722 ℃ (1) 扫码查看

有很多同学在使用vue开发项目时,可能会用的到类似vue-element-admin的模板进行开发,老版本的项目在npm install时往往或报错tui-editor安装失败,这是一个编辑器插件,最近潘老师在安装时也遇到了该问题,我们一起来看看是怎么解决的吧!

一、产生原因

其实这个问题产生的原因很简单,就是原先的tui-editor插件(富文本编辑器插件)换了个名称,现在已经更名为toast-ui/editor因此安装不了,从而报错!

二、解决方案

解决方案其实也很简单,具体如下:

第1步:插件更名

首先将package.json中的tui-editor那一行修改为"@toast-ui/editor": "^3.1.3",

第2步:文件更名

进入\src\components\MarkdownEditor\index.vue文件,将他的所有import删除换成下面四行

import 'codemirror/lib/codemirror.css'
import '@toast-ui/editor/dist/toastui-editor.css'
import Editor from '@toast-ui/editor'
import defaultOptions from './default-options'

第3步:方法更名

1)把该页面(还是第二步中的文件)的getValuesetValue分别换成getMarkdownsetMarkdown

2)把页面中的所有tui-editor全部替换为@toast-ui/editor

第4步:重新安装

重新执行npm install安装依赖就解决了。

总结

以上就是npm或cnpm install 安装tui-editor报错时的解决方案,亲测有效哦!


版权声明:本站文章,如无说明,均为本站原创,转载请注明文章来源。如有侵权,请联系博主删除。
本文链接:https://www.panziye.com/java/web/4794.html
喜欢 (49)
请潘老师喝杯Coffee吧!】
分享 (0)
用户头像
发表我的评论
取消评论
表情 贴图 签到 代码

Hi,您需要填写昵称和邮箱!

  • 昵称【必填】
  • 邮箱【必填】
  • 网址【可选】

(1) 个小伙伴在畅所欲言
  1. 用户头像
    ERROR  Failed to compile with 2 errors                                                                                      23:54:26These dependencies were not found:* @toast-ui/editor in ./node_modules/cache-loader/dist/cjs.js??ref--12-0!./node_modules/babel-loader/lib!./node_modules/cache-loader/dist/cjs.js??ref--0-0!./node_modules/vue-loader/lib??vue-loader-options!./src/components/MarkdownEditor/index.vue?vue&type=script&lang=js&* @toast-ui/editor/dist/toas@toast-ui/editor.css in ./node_modules/cache-loader/dist/cjs.js??ref--12-0!./node_modules/babel-loader/lib!./node_modules/cache-loader/dist/cjs.js??ref--0-0!./node_modules/vue-loader/lib??vue-loader-options!./src/components/MarkdownEditor/index.vue?vue&type=script&lang=js&To install them, you can run: npm install --save @toast-ui/editor @toast-ui/editor/dist/toas@toast-ui/editor.cssError from chokidar (C:\): Error: EBUSY: resource busy or locked, lstat 'C:\DumpStack.log.tmp'
    chayu 2023-03-19 23:56 回复