「Taro」Taro CLI 与本地安装运行时框架 @tarojs/taro-weapp 版本不一致

解决Taro版本冲突
本文详细记录了在更新Taro版本过程中遇到的问题及解决方案,包括如何正确切换Taro版本、解决本地与项目版本不一致的错误,以及处理编译和依赖安装时的常见问题。

使用npm切换版本也可,需要提前进行reset cache,并采用全局操作。

npm install -g @tarojs/cli@1.3.10


-------------------------------2020.03.30 更新-------------------------------


啊啊啊啊啊!成功更新项目taro版本后,可以使用yarn dev:weapp成功编译,但是在微信开发工具中出现报错。
0216.PNG
搞了几天也没有明确报错原因,所以打算还是回退本地的taro版本,但是使用npm卸载或者切换版本以及直接删除npm目录下的@taro都无效之后,使用yarn进行了下taro版本切换操作然后成功了。

yarn add @tarojs/cli@1.3.10


想知道为什么?!!!


-------------------------------2020.02.17-------------------------------


为原先开发小程序的时候Taro还是1.3.10,现在换了电脑安装了Taro 2.0,结果编译运行项目的时候就报错了。
0214.PNG


本地Taro版本与项目Taro版本不一致。


所以需要更新项目的Taro版本。

# 首先更新 Taro CLI 工具,全部升级至最新版本

# taro
$ taro update self 
# npm
npm i -g @tarojs/cli
# yarn
yarn global add @tarojs/cli

# 更新项目中 Taro 相关的依赖

$ taro update project 


本地更新至了Taro 2.0.3,但是taro update project更新后,package.json内@tarojs/taro-weapp为1.3.37,导致本地与项目Taro版本还是不一致,所以在使用taro update project时添加相应的版本号。


但是再次编译还是报不一致的错误,需要删除node_modules之后重新安装依赖。




警告:Warning: React version not specified in eslint-plugin-react settings. See https://github.com/yannickcr/eslint-plugin-react#configuration .
原因:eslint-plugin-react未指定react版本。

# Install ESLint either locally or globally. (Note that locally, per project, is strongly preferred)
$ npm install eslint --save-dev

# If you installed ESLint globally, you have to install React plugin globally too. Otherwise, install it locally.
$ npm install eslint-plugin-react --save-dev

并在eslintrc.js中指定react版本但是还是无效!!!!

1. settings: {
2. 	react: {
3.         version: "detect"
4.     }
5. }

{ "name": "jz-taro", "version": "4.0.0", "private": true, "description": "jiezhang", "templateInfo": { "name": "taro-ui", "typescript": true, "css": "stylus" }, "scripts": { "build:weapp": "set NODE_ENV=production && taro build --type weapp", "build:swan": "taro build --type swan", "build:alipay": "taro build --type alipay", "build:tt": "taro build --type tt", "build:h5": "taro build --type h5", "build:rn": "taro build --type rn", "build:qq": "taro build --type qq", "build:jd": "taro build --type jd", "build:quickapp": "taro build --type quickapp", "pro:weapp": "set NODE_ENV=production && taro build --type weapp --watch", "dev:weapp": "taro build --type weapp --watch", "dev:swan": "npm run build:swan -- --watch", "dev:alipay": "npm run build:alipay -- --watch", "dev:tt": "npm run build:tt -- --watch", "dev:h5": "npm run build:h5 -- --watch", "dev:rn": "npm run build:rn -- --watch", "dev:qq": "npm run build:qq -- --watch", "dev:jd": "npm run build:jd -- --watch", "dev:quickapp": "npm run build:quickapp -- --watch" }, "browserslist": [ "last 3 versions", "Android >= 4.1", "ios >= 8" ], "author": "", "dependencies": { "@babel/runtime": "^7.7.7", "@tarojs/cli": "3.6.38", "@tarojs/components": "3.6.38", "@tarojs/plugin-framework-react": "3.6.38", "@tarojs/plugin-platform-weapp": "3.6.38", "@tarojs/react": "3.6.38", "@tarojs/runtime": "3.6.38", "@tarojs/taro": "3.6.38", "date-fns": "^2.21.3", "lodash": "4.17.15", "mobx": "5.15.7", "mobx-react": "6.3.1", "react": "^16.8.0", "react-dom": "^16.8.0", "taro-react-echarts": "^1.2.2", "taro-ui": "^3.3.0" }, "devDependencies": { "@babel/core": "^7.8.0", "@tarojs/mini-runner": "3.6.38", "@tarojs/webpack-runner": "3.6.38", "@types/react": "^17.0.2", "@types/webpack-env": "^1.13.6", "@typescript-eslint/eslint-plugin": "^4.15.1", "@typescript-eslint/parser": "^4.15.1", "babel-preset-taro": "3.2.0", "eslint": "^6.8.0", "eslint-config-taro": "3.2.0", "eslint-plugin-import": "^2.12.0", "eslint-plugin-react": "^7.8.2", "eslint-plugin-react-hooks": "^4.2.0", "node-sass": "^9.0.0", "stylelint": "9.3.0", "typescript": "^4.1.0" } } 这是packages.json中的配置
09-24
评论
成就一亿技术人!
拼手气红包6.0元
还能输入1000个字符
 
红包 添加红包
表情包 插入表情
 条评论被折叠 查看
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

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

抵扣说明:

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

余额充值