【vue】执行npm install element-ui -S报错

执行npm install element-ui -S报错

npm install element-ui -S
npm ERR! code ERESOLVE
npm ERR! ERESOLVE unable to resolve dependency tree
npm ERR! While resolving: my-project0817@0.1.0
npm ERR! Found: vue@3.3.4
npm ERR! node_modules/vue
npm ERR!   vue@"^3.2.13" from the root project
npm ERR!
npm ERR! Could not resolve dependency:
npm ERR! peer vue@"^2.5.17" from element-ui@2.15.13
npm ERR! node_modules/element-ui
npm ERR!   element-ui@"*" from the root project
npm ERR!
npm ERR! Fix the upstream dependency conflict, or retry
npm ERR! this command with --force or --legacy-peer-deps
npm ERR! to accept an incorrect (and potentially broken) dependency resolution.
npm ERR!
npm ERR!
npm ERR! For a full report see:
npm ERR! C:\Users\LENOVO\AppData\Local\npm-cache\_logs\2023-08-17T12_24_41_623Z-eresolve-report.txt

npm ERR! A complete log of this run can be found in: C:\Users\LENOVO\AppData\Local\npm-cache\_logs\2023-08-17T12_24_41_623Z-debug-0.log

解决方法

npm install element-plus --save

原因

参考的网站错误了,

npm install element-ui -S 

对应的是https://element.eleme.cn/#/zh-CN/component/installation

npm install element-plus --save

对应的是 https://element-plus.gitee.io/zh-CN/

element-ui 的版本是这样匹配的vue@“^2.5.17” from element-ui@2.15.13
element-plus 匹配的版本是vue@“^5.08”

  • 0
    点赞
  • 3
    收藏
    觉得还不错? 一键收藏
  • 1
    评论
引用\[1\]:新建 /src/components/element/index.js 文件,index.js 示例代码如下: import { Button, Input, Radio, Table, Form } from 'element-ui' const coms = \[ Button, Input, Radio, Table, Form \] export default { install(Vue, options){ coms.map(c => { Vue.component(c.name, c) }) } } 。 引用\[2\]:在 main.js 中引入自定义 element 插件: import Vue from 'vue' import App from './App.vue' import router from './router' import store from './store' //引入 element 插件 import element from './components/element' Vue.use(element) Vue.config.productionTip = false new Vue({ router, store, render: h => h(App) }).$mount('#app') 。 引用\[3\]:在 main.js 入口文件中引入组件: import Vue from 'vue' import App from './App.vue' import router from './router' import store from './store' import { Button } from 'element-ui'; // 按需引入组件 Vue.component(Button.name, Button); // 注册全局组件 // 或 // Vue.use(Button) // 或指定组件名称 // Vue.component('my-button', Button); Vue.config.productionTip = false new Vue({ router, store, render: h => h(App) }).$mount('#app') 第6步:使用组件 <template> <div id="app"> <el-button type="primary">按钮</el-button> <!-- <my-button>按钮</my-button> --> </div> </template> 封装 Element 模块 。 问题: npmi element-ui --save 回答: npmi element-ui --save 是一个错误的命令。正确的命令应该是 npm install element-ui --save。这个命令用于在你的项目中安装 element-ui 包,并将其添加到项目的依赖中。 #### 引用[.reference_title] - *1* *2* *3* [Vue 项目中按需引入 ElementUI 的正确方法](https://blog.csdn.net/p445098355/article/details/121207285)[target="_blank" data-report-click={"spm":"1018.2226.3001.9630","extra":{"utm_source":"vip_chatgpt_common_search_pc_result","utm_medium":"distribute.pc_search_result.none-task-cask-2~all~insert_cask~default-1-null.142^v91^insertT0,239^v3^insert_chatgpt"}} ] [.reference_item] [ .reference_list ]

“相关推荐”对你有帮助么?

  • 非常没帮助
  • 没帮助
  • 一般
  • 有帮助
  • 非常有帮助
提交
评论 1
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

当前余额3.43前往充值 >
需支付:10.00
成就一亿技术人!
领取后你会自动成为博主和红包主的粉丝 规则
hope_wisdom
发出的红包
实付
使用余额支付
点击重新获取
扫码支付
钱包余额 0

抵扣说明:

1.余额是钱包充值的虚拟货币,按照1:1的比例进行支付金额的抵扣。
2.余额无法直接购买下载,可以购买VIP、付费专栏及课程。

余额充值