Taro项目环境问题

335 阅读2分钟

taro 查看对应的taro版本 taro info

更新项目的 taro 版本和项目的版本一致,导致编译出错

Error: .presets[0] may only be a two-tuple or three-tuple at assertPluginItem (D:\Taro资料\taro-mall\node_modules@babel\core\lib\config\validation\option-assertions.js:249:13) at D:\Taro资料\taro-mall\node_modules@babel\core\lib\config\validation\option-assertions.js:236:30 at Array.forEach () at assertPluginList (D:\Taro资料\taro-mall\node_modules@babel\core\lib\config\validation\option-assertions.js:236:9) at D:\Taro资料\taro-mall\node_modules@babel\core\lib\config\validation\options.js:118:5 at Array.forEach () at validateNested (D:\Taro资料\taro-mall\node_modules@babel\core\lib\config\validation\options.js:94:21) at validate (D:\Taro资料\taro-mall\node_modules@babel\core\lib\config\validation\options.js:85:10) at D:\Taro资料\taro-mall\node_modules@babel\core\lib\config\config-chain.js:204:34 at cachedFunction (D:\Taro资料\taro-mall\node_modules@babel\core\lib\config\caching.js:60:27) at cachedFunction.next () at evaluateSync (D:\Taro资料\taro-mall\node_modules\gensync\index.js:251:28) at sync (D:\Taro资料\taro-mall\node_modules\gensync\index.js:89:14) at buildRootChain (D:\Taro资料\taro-mall\node_modules@babel\core\lib\config\config-chain.js:94:27) at buildRootChain.next () at loadPrivatePartialConfig (D:\Taro资料\taro-mall\node_modules@babel\core\lib\config\partial.js:103:62),./src/pages/ucenter/address/address.config.js

升级项目中的taro版本号,与本地全局安装一致

//升级项目中的taro版本号

taro update project 版本号

// 升级本地依赖的taro/cli 版本号 

yarn add @tarojs/cli@3.0.25 --dev

taro update self 版本号

对项目进行编译

yarn dev:weapp 

npm dev:weapp

taro 版本升级处理 注意事项

  1. / 2. /版本升级到3. / 处理 文件调整主要如下 项目根目录中/config/index 中的 plugins 对象改为数组,去除babel的配置 增加babel.config.js 配置文件, // babel-preset-taro 更多选项和默认值: // github.com/NervJS/taro… module.exports = { presets: [ ['taro', { framework: 'react', ts: true }] ] } /config/index 中去除页面配置部分 增加,*.config.js,具体文件配置如下:app.config.js export default { pages: [ 'pages/index/index', 'pages/ucenter/index/index', 'pages/catalog/catalog', 'pages/cart/cart', 'pages/custom/page/page', ], window: { backgroundTextStyle: 'light', navigationBarBackgroundColor: '#fff', navigationBarTitleText: 'WeChat', navigationBarTextStyle: 'black' }, tabBar: { "backgroundColor": "#fafafa", "borderStyle": "white", "selectedColor": "#AB956D", "color": "#666", "list": [{ "pagePath": "pages/index/index", "iconPath": './static/images/home.png', "selectedIconPath": './static/images/home@selected.png', "text": "首页" } ] }, //微信分包机制 // subpackages: [{ // root: "packages", // name: "pack2", // pages: [ // 'pages/demo/index' // ], // }], "networkTimeout": { "request": 10000, "downloadFile": 10000 }, "debug": true, }

/config/index 中增加 关于framework 的配置 framework:'react'