最近打开这个项目,yarn dev:weapp 时候报错,cli 和项目版本冲突如下:

kyle@DESKTOP-LIPAM5T MINGW64 /d/yuwei-workspacke/web-frontend/icommunity/weapp-fontend/trunk/icommunity-weapp (master)
$ yarn dev:weapp
yarn run v1.22.4
$ npm run build:weapp -- --watch

> icommunity-miniapp@1.0.0 build:weapp D:\yuwei-workspacke\web-frontend\icommunity\weapp-fontend\trunk\icommunity-weapp
> taro build --type weapp "--watch"

� Taro v2.1.5

开始编译项目 icommunity-miniapp
错误  版本问题  Taro CLI 与本地安装运行时框架 @tarojs/taro-weapp 版本不一致, 请确保版本一致!
提示  升级命令  升级到最新CLI:taro update self   升级到最新依赖库:taro update project
提示  升级文档  请参考 "常用 CLI 命令"中"更新" 章节:https://taro-docs.jd.com/taro/docs/GETTING-STARTED.html

Taro CLI:2.1.5             路径:C:\Users\kyle\AppData\Local\Yarn\Data\global\node_modules\@tarojs\cli\package.json
@tarojs/taro-weapp:1.3.39   路径:D:\yuwei-workspacke\web-frontend\icommunity\weapp-fontend\trunk\icommunity-weapp\node_modules\@tarojs\taro-weapp\package.json

npm ERR! code ELIFECYCLE
npm ERR! errno 1
npm ERR! icommunity-miniapp@1.0.0 build:weapp: `taro build --type weapp "--watch"`
npm ERR! Exit status 1
npm ERR!
npm ERR! Failed at the icommunity-miniapp@1.0.0 build:weapp script.
npm ERR! This is probably not a problem with npm. There is likely additional logging output above.

npm ERR! A complete log of this run can be found in:
npm ERR!     C:\Users\kyle\AppData\Roaming\npm-cache\_logs\2020-04-21T04_54_27_742Z-debug.log
error Command failed with exit code 1.
info Visit https://yarnpkg.com/en/docs/cli/run for documentation about this command.

package.json文件

	"dependencies": {
		"@tarojs/components": "1.3.39",
		"@tarojs/router": "1.3.39",
		"@tarojs/taro": "1.3.39",
		"@tarojs/taro-alipay": "1.3.39",
		"@tarojs/taro-h5": "1.3.39",
		"@tarojs/taro-qq": "1.3.39",
		"@tarojs/taro-quickapp": "1.3.39",
		"@tarojs/taro-swan": "1.3.39",
		"@tarojs/taro-tt": "1.3.39",
		"@tarojs/taro-weapp": "1.3.39",
		"nerv-devtools": "^1.5.6",
		"nervjs": "^1.5.6",
		"taro-ui": "^2.2.4"
	},
	"devDependencies": {
		"@tarojs/plugin-babel": "1.3.39",
		"@tarojs/plugin-csso": "1.3.39",
		"@tarojs/plugin-sass": "1.3.39",
		"@tarojs/plugin-uglifyjs": "1.3.39",
		"@tarojs/webpack-runner": "1.3.39",

安装了对应 版本的 cli 工具

$ yarn global add @tarojs/cli@1.3.39

项目ok了

kyle@DESKTOP-LIPAM5T MINGW64 /d/yuwei-workspacke/web-frontend/icommunity/weapp-fontend/trunk/icommunity-weapp (master)
$ yarn dev:weapp
yarn run v1.22.4
$ npm run build:weapp -- --watch

> icommunity-miniapp@1.0.0 build:weapp D:\yuwei-workspacke\web-frontend\icommunity\weapp-fontend\trunk\icommunity-weapp
> taro build --type weapp "--watch"

� Taro v1.3.39

开始编译项目 icommunity-miniapp
生成  工具配置  dist/project.config.json
编译  入口文件  src/app.jsx
拷贝  NPM文件   dist/npm/@tarojs/taro/dist/index.js
拷贝  NPM文件   dist/npm/@tarojs/taro/index.js
拷贝  NPM文件   dist/npm/@tarojs/taro-weapp/dist/index.js
拷贝  NPM文件   dist/npm/@tarojs/taro-weapp/index.js
生成  入口配置  dist/app.json
生成  入口文件  dist/app.js
生成  入口样式  dist/app.wxss
编译  所有页面

记得之前安装 taro 提示操作,也可以解决问题

Logo

智屏生态联盟致力于大屏生态发展,利用大屏快应用技术降低开发者开发、发布大屏应用门槛

更多推荐