Vue学习-1(2)使用@vue/cli创建项目

博客提到cnpm不怎么维护了,同时指出yarn比npm稍快,还提醒不要用npm来安装yarn,为开发者在包管理工具的选择上提供了参考。

image-20201226174255718

yarn global add @vue/cli@4.1.2
npm install --global @vue/cli@4.1.2

image-20201226174541633

image-20201226174924684

修改'~/.vuerc'中"useTaobaoRegistry"为true

image-20201226175008557

image-20201226175215932

Use history mode for router? NO
CSS pre-processor?SCSS(dart-sass)

image-20201226175418644
image-20201226175456455
image-20201226175543970
image-20201226175619028

  • cnpm不怎么维护了

  • yarn比npm稍快(别用npm装yarn)

run `npm fund` for details fanwei@192 eam % npm install @vue/cli-service@latest --save-dev npm WARN ERESOLVE overriding peer dependency npm WARN While resolving: eam@1.0.5 npm WARN Found: @vue/cli-service@4.5.19 npm WARN node_modules/@vue/cli-service npm WARN peer @vue/cli-service@"^3.0.0 || ^4.0.0-0" from @vue/cli-plugin-babel@4.5.19 npm WARN node_modules/@vue/cli-plugin-babel npm WARN dev @vue/cli-plugin-babel@"~4.5.0" from the root project npm WARN 3 more (@vue/cli-plugin-router, @vue/cli-plugin-vuex, the root project) npm WARN npm WARN Could not resolve dependency: npm WARN peer @vue/cli-service@"^3.0.0 || ^4.0.0-0" from @vue/cli-plugin-babel@4.5.19 npm WARN node_modules/@vue/cli-plugin-babel npm WARN dev @vue/cli-plugin-babel@"~4.5.0" from the root project npm WARN ERESOLVE overriding peer dependency npm WARN While resolving: eam@1.0.5 npm WARN Found: @vue/cli-service@4.5.19 npm WARN node_modules/@vue/cli-service npm WARN peer @vue/cli-service@"^3.0.0 || ^4.0.0-0" from @vue/cli-plugin-babel@4.5.19 npm WARN node_modules/@vue/cli-plugin-babel npm WARN dev @vue/cli-plugin-babel@"~4.5.0" from the root project npm WARN 3 more (@vue/cli-plugin-router, @vue/cli-plugin-vuex, the root project) npm WARN npm WARN Could not resolve dependency: npm WARN peer @vue/cli-service@"^3.0.0 || ^4.0.0-0" from @vue/cli-plugin-router@4.5.19 npm WARN node_modules/@vue/cli-plugin-router npm WARN @vue/cli-plugin-router@"^4.5.19" from @vue/cli-service@4.5.19 npm WARN 1 more (the root project) npm WARN ERESOLVE overriding peer dependency npm WARN While resolving: eam@1.0.5 npm WARN Found: @vue/cli-service@4.5.19 npm WARN node_modules/@vue/cli-service npm WARN peer @vue/cli-service@"^3.0.0 || ^4.0.0-0" from @vue/cli-plugin-babel@4.5.19 npm WARN node_modules/@vue/cli-plugin-babel npm WARN dev @vue/cli-plugin-babel@"~4.5.0" from the root project npm WARN 3 more (@vue/cli-plugin-router, @vue/cli-plugin-vuex, the root project) npm WARN npm WARN Could not
最新发布
03-31
<think>嗯,用户遇到了Vue CLI插件与@vue/cli-service的依赖冲突问题,显示ERESOLVE错误。我需要先理解这个问题的常见原因。根据引用[1]到[4],可能的问题是对等依赖版本不匹配,比如eslint-plugin-vueVue、Vant或ECharts的版本冲突。 首先,应该检查项目中的依赖版本是否兼容。例如,引用[1]提到降级eslint-plugin-vue到7.0.0版本可能解决冲突,而引用[3]指出@vue/cli-plugin-eslint可能对eslint版本有特定要求。此外,引用[2]和[4]都提到项目中的依赖包版本不一致导致的冲突。 解决步骤可能包括:1. 使用npm ls分析依赖树,找出具体冲突的包。2. 升级或降级相关依赖到兼容版本,比如升级@vue/cli-service到最新或与插件兼容的版本。3. 使用--legacy-peer-deps绕过冲突,但可能不稳定。4. 如果问题依旧,考虑创建项目并逐步迁移依赖。 用户可能需要手动调整package.json中的版本,然后重新安装。此外,确保所有Vue CLI插件与核心库版本匹配也很重要。例如,如果@vue/cli-service是4.x,插件也应该是4.x版本。如果用户升级到Vue 3,可能需要使用Vue CLI 5.x。 还需要注意其他依赖如Vant或ECharts是否与Vue版本兼容,引用[2]提到Vant需要Vue 3,而ECharts可能需要特定版本。因此,全面检查所有相关依赖的版本兼容性是关键。</think>### 解决Vue CLI插件与@vue/cli-service依赖冲突的步骤 #### 1. 分析依赖树 通过命令查看具体冲突来源: ```bash npm ls @vue/cli-service eslint-plugin-vue vue ``` 若出现类似`UNMET PEER DEPENDENCY`警告,表示存在版本不匹配问题[^2][^3] #### 2. 版本兼容性处理 根据引用[1][3][4]建议: ```bash # 升级核心工具链 npm install --save-dev @vue/cli-service@latest # 同步更新相关插件 npm install --save-dev @vue/cli-plugin-eslint@latest eslint-plugin-vue@^7.0.0 # 显式指定Vue版本(若使用Vue 3) npm install vue@3.2.45 ``` #### 3. 强制安装模式 对于暂时无法解决的冲突,可尝试: ```bash npm install --legacy-peer-deps ``` 此模式会忽略部分peer依赖检查,但可能引发运行时问题[^4] #### 4. 依赖清理策略 ```bash # 清除缓存后重试 rm -rf node_modules package-lock.json npm cache clean --force npm install ``` #### 5. 项目级版本控制 在`package.json`中显式指定版本范围: ```json { "devDependencies": { "@vue/cli-service": "^4.5.19", "eslint-plugin-vue": "^7.0.0", "vue": "^2.6.14 || ^3.2.0" } } ``` ### 版本兼容对照表 | 组件 | Vue 2兼容版本 | Vue 3兼容版本 | |--------------------|------------------|------------------| | @vue/cli-service | 4.x | 5.x | | eslint-plugin-vue | 6.x | 7.x+ | | @vue/cli-plugin-eslint | 4.x | 5.x | ### 典型错误场景 1. **Vue 2项目安装Vant4**:需要强制指定Vant3版本 ```bash npm install vant@latest-2 ``` 2. **ESLint版本冲突**:引用[3]显示需保持`eslint@>=1.6.0 <7.0.0`范围 3. **Less加载问题**:引用[4]建议检查`less-loader`与webpack版本的兼容性
评论
成就一亿技术人!
拼手气红包6.0元
还能输入1000个字符
 
红包 添加红包
表情包 插入表情
 条评论被折叠 查看
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

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

抵扣说明:

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

余额充值