UnhandledPromiseRejectionWarning: TypeError: items.forEach is not a function
-
todoList@1.0.0 build:h5 /Users/coderloy/2020-target-ali/car/demo/taro-todoList
taro build --type h5 "--watch"Taro v2.2.2
(node:1851) UnhandledPromiseRejectionWarning: TypeError: items.forEach is not a function
at /usr/local/lib/node_modules/@tarojs/cli/node_modules/@tarojs_service@2.2.2@@tarojs/service/dist/utils/index.js:17:15
at /usr/local/lib/node_modules/@tarojs/cli/node_modules/@tarojs_service@2.2.2@@tarojs/service/dist/utils/index.js:33:51
at Kernel.initPresetsAndPlugins (/usr/local/lib/node_modules/@tarojs/cli/node_modules/@tarojs_service@2.2.2@@tarojs/service/dist/Kernel.js:72:107)
at Kernel.<anonymous> (/usr/local/lib/node_modules/@tarojs/cli/node_modules/@tarojs_service@2.2.2@@tarojs/service/dist/Kernel.js:40:18)
at Generator.next (<anonymous>)
at /usr/local/lib/node_modules/@tarojs/cli/node_modules/@tarojs_service@2.2.2@@tarojs/service/dist/Kernel.js:8:71
at new Promise (<anonymous>)
at __awaiter (/usr/local/lib/node_modules/@tarojs/cli/node_modules/@tarojs_service@2.2.2@@tarojs/service/dist/Kernel.js:4:12)
at Kernel.init (/usr/local/lib/node_modules/@tarojs/cli/node_modules/@tarojs_service@2.2.2@@tarojs/service/dist/Kernel.js:36:16)
at Kernel.<anonymous> (/usr/local/lib/node_modules/@tarojs/cli/node_modules/@tarojs_service@2.2.2@@tarojs/service/dist/Kernel.js:239:24)
(node:1851) 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(). (rejection id: 2)
(node:1851) [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.
Done in 1.39s.
怀疑是版本问题,卸载重新安装也不行。请问是什么原因?
-
打断点,观察一下items,估计是初始值的问题,可能是string或者number了
-
确实是版本问题
你的taro版本和你的依赖版本没有统一
1.先打开你的package.json 看看版本2.在看看你的taro版本
解决方案:
npm install -g @tarojs/cli@1.3.20 这里版本改成依赖版本
然后从新运行 就ok了taro doctor 这个命令也可以帮忙检查依赖等是否存在问题,并尝试给出解决方案哦
https://nervjs.github.io/taro/docs/GETTING-STARTED.html#taro-doctor