lsqy/taro-music

yarn dev:weapp时提示 items.forEach is not a function

yangzqv opened this issue · 6 comments

(node:23561) UnhandledPromiseRejectionWarning: TypeError: items.forEach is not a function
at /usr/local/lib/node_modules/@tarojs/cli/node_modules/@tarojs_service@2.2.3@@tarojs/service/dist/utils/index.js:17:15
at /usr/local/lib/node_modules/@tarojs/cli/node_modules/
@tarojs_service@2.2.3@@tarojs/service/dist/utils/index.js:33:51
at Kernel.initPresetsAndPlugins (/usr/local/lib/node_modules/@tarojs/cli/node_modules/@tarojs_service@2.2.3@@tarojs/service/dist/Kernel.js:72:107)
at Kernel. (/usr/local/lib/node_modules/@tarojs/cli/node_modules/
@tarojs_service@2.2.3@@tarojs/service/dist/Kernel.js:40:18)
at Generator.next ()
at /usr/local/lib/node_modules/@tarojs/cli/node_modules/@tarojs_service@2.2.3@@tarojs/service/dist/Kernel.js:8:71
at new Promise ()
at __awaiter (/usr/local/lib/node_modules/@tarojs/cli/node_modules/
@tarojs_service@2.2.3@@tarojs/service/dist/Kernel.js:4:12)
at Kernel.init (/usr/local/lib/node_modules/@tarojs/cli/node_modules/@tarojs_service@2.2.3@@tarojs/service/dist/Kernel.js:36:16)
at Kernel. (/usr/local/lib/node_modules/@tarojs/cli/node_modules/
@tarojs_service@2.2.3@@tarojs/service/dist/Kernel.js:239:24)
(node:23561) UnhandledPromiseRejectionWarning: Unhandled promise rejection. This error originated either by throwing inside of an async function without a catch block, or by rejecting a promise which was not handled with .catch(). To terminate the node process on unhandled promise rejection, use the CLI flag --unhandled-rejections=strict (see https://nodejs.org/api/cli.html#cli_unhandled_rejections_mode). (rejection id: 2)
(node:23561) [DEP0018] DeprecationWarning: Unhandled promise rejections are deprecated. In the future, promise rejections that are not handled will terminate the Node.js process with a non-zero exit code.

lsqy commented

先确认下你的taro-cli的版本与项目中taro的版本是否保持一致

大佬,不一致,我的是最新版本的。

lsqy commented

那可以通过执行taro update self(mac或者linux前面需要加上sudo)以及taro update project进行cli与项目依赖的更新保持一致,否则将会导致项目无法正常运行

yarn dev:weapp时提示Taro 配置有误,请检查! [✗] plugins 应该为数组类型,版本确认一致

npm run dev:h5 时报错
� Failed to compile.

./.temp/app.js
Module build failed (from ./node_modules/@tarojs/webpack-runner/node_modules/babel-loader/lib/index.js):
SyntaxError: C:/Users/Administrator/Desktop/taro-music/.temp/app.js: Unexpected token (126:9)

124 | ;
125 | }

126 | config = {
| ^
127 | pages: ["/pages/index/index", "/pages/dailyRecommend/index", "/pages/my/index", "/pages/videoDetail/index", "/pages/search/index", "/pages/user/index", "/pages/djprogramListDetail/index", "/pages/searchResult/index",
128 | // 'pages/search/index',
129 | "/pages/songDetail/index", "/pages/myFans/index", "/pages/myFocus/index", "/pages/myEvents/index", "/pages/login/index", "/pages/playListDetail/index", "/pages/recentPlay/index"],

npm run dev:h5 时报错
� Failed to compile.
./.temp/app.js
Module build failed (from ./node_modules/@tarojs/webpack-runner/node_modules/babel-loader/lib/index.js):
SyntaxError: C:/Users/Administrator/Desktop/taro-music/.temp/app.js: Unexpected token (126:9)
124 | ;
125 | }

126 | config = {
| ^
127 | pages: ["/pages/index/index", "/pages/dailyRecommend/index", "/pages/my/index", "/pages/videoDetail/index", "/pages/search/index", "/pages/user/index", "/pages/djprogramListDetail/index", "/pages/searchResult/index",
128 | // 'pages/search/index',
129 | "/pages/songDetail/index", "/pages/myFans/index", "/pages/myFocus/index", "/pages/myEvents/index", "/pages/login/index", "/pages/playListDetail/index", "/pages/recentPlay/index"],

打开config/index.js,检查babel配置项是否存在:

config = {
  babel: {
    sourceMap: true,
    presets: [
      [
        "env",
        {
          modules: false
        }
      ]
    ],
    plugins: [
      "transform-decorators-legacy",
      "transform-class-properties",
      "transform-object-rest-spread"
    ]
  },
  plugins: [
    "@tarojs/plugin-sass"
  ]
}