vue-element-admin npm i error solution

After consulting the information, it was finally solved from the following aspects. In fact, it can basically be confirmed that the problem is due to the version of the tui-editor plug-in

1. The node version is low, I am using 16.18.1 now

2. Pull the vue-element-admin project from git

3. vscode opens the project, note that the root directory is the project root directory, do not open from the project root directory, and then run the following code in the root directory of the vscode terminal

rm -rf node_modules
rm package-lock.json
npm cache clear --force

4. Change the tui-editor line in package.json to (emphasis)

"@toast-ui/editor": "^3.1.3",

5. Next, modify src -> components->MarkdownEditor->index.vue

① Replace all imports at the beginning with the following four lines

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

② Replace the getValue and setValue inside with getMarkdown and setMarkdown respectively, and replace all tui-editors with @toast-ui/editor

Execute npm install after saving, it is faster to install using Taobao image:

npm install --registry=https://registry.npm.taobao.org

There is another problem here. If you find that this operation is still an error, I have this problem. Check whether the above import has been automatically changed. It may be that vscode or npm automatically changed the import when downloading the package.

Finally, npm run dev should work  

Guess you like

Origin blog.csdn.net/qq_59650449/article/details/128435026