xcjack
xcjack
  • 发布:2020-08-26 01:02
  • 更新:2021-11-22 14:14
  • 阅读:2881

【报Bug】新版编译报:TypeError: Cannot read property 'length' of undefined 错误,太多页面都报这个错误。以前编译很正常。

分类:uni-app

产品分类: uniapp/App

PC开发环境操作系统: Windows

PC开发环境操作系统版本号: 10

HBuilderX类型: 正式

HBuilderX版本号: 2.8.8

手机系统: Android

手机系统版本号: Android 8.1

手机厂商: 华为

手机机型: 没在手机上运行,打包编译报错

页面类型: vue

打包方式: 云端

项目创建方式: HBuilderX

操作步骤:

预期结果:

实际结果:

bug描述:

以前打包编译都没问题。现在升级以后就出现这个问题。不云打包本地编译调试运行都是好的。只要云打包编译时就报:TypeError: Cannot read property 'length' of undefined 而且是多个文件报这个错误。连app.vue文件中连length都没有也报错。现截图了login.vue文件的报错行和length的地方。这应该是误报吧? 我的password是一个字符串变量。这是可以length的呀。运行的时候都没问题。云打包编译就出问题。希望你们能解决一下。

2020-08-26 01:02 负责人:无 分享
已邀请:
xcjack

xcjack (作者) - 后端工程师

没人回答呀。再顶一下

xcjack

xcjack (作者) - 后端工程师

很奇怪,为什么报 length 未定义呢?以前版本编译都没有这样的错误。而且在本地调试运行都没问题。云打包的时候才出这个问题。跟V3编译有关系吗?

xcjack

xcjack (作者) - 后端工程师

报错的页面如比login.vue这个页。使用length的地方肯定都是合法的。都是字符串变量 比如 password.length .这完全合法,也不存在null的问题,要不本地编译也不会通过。就是这个云打包前的编译会有问题。

DCloud_UNI_GSQ

DCloud_UNI_GSQ

之前正常的版本是多少,另外,我该怎样复现一下此问题?

1***@qq.com

1***@qq.com

我在使用HBuilderX 2.8.3进行离线打包的时候也遇到了这个问题

[HBuilder] 15:28:21.297 Browserslist: caniuse-lite is outdated. Please run:
[HBuilder] 15:28:21.297 npx browserslist@latest --update-db
[HBuilder] 15:28:39.147 Module build failed (from ./node_modules/postcss-loader/src/index.js):
[HBuilder] 15:28:39.148 TypeError: Cannot read property 'length' of undefined
[HBuilder] 15:28:39.177 at /Users/hedy/Desktop/Git/APP/components/hx-bar/hx-subbar.vue:35:3
[HBuilder] 15:28:39.179 at module.exports (/Applications/HBuilderX.app/Contents/HBuilderX/plugins/uniapp-cli/node_modules/postcss-value-parser/lib/unit.js:9:22)
[HBuilder] 15:28:39.194 at args.forEach (/Applications/HBuilderX.app/Contents/HBuilderX/plugins/uniapp-cli/node_modules/postcss-minify-gradients/dist/index.js:66:61)
[HBuilder] 15:28:39.213 at Array.forEach (<anonymous>)
[HBuilder] 15:28:39.213 at decl.value.walk.node (/Applications/HBuilderX.app/Contents/HBuilderX/plugins/uniapp-cli/node_modules/postcss-minify-gradients/dist/index.js:60:18)
[HBuilder] 15:28:39.231 at walk (/Applications/HBuilderX.app/Contents/HBuilderX/plugins/uniapp-cli/node_modules/postcss-value-parser/lib/walk.js:7:16)
[HBuilder] 15:28:39.249 at ValueParser.walk (/Applications/HBuilderX.app/Contents/HBuilderX/plugins/uniapp-cli/node_modules/postcss-value-parser/lib/index.js:18:3)
[HBuilder] 15:28:39.250 at optimise (/Applications/HBuilderX.app/Contents/HBuilderX/plugins/uniapp-cli/node_modules/postcss-minify-gradients/dist/index.js:43:59)
[HBuilder] 15:28:39.271 at /Applications/HBuilderX.app/Contents/HBuilderX/plugins/uniapp-cli/node_modules/postcss-loader/node_modules/postcss/lib/container.js:190:18
[HBuilder] 15:28:39.289 at /Applications/HBuilderX.app/Contents/HBuilderX/plugins/uniapp-cli/node_modules/postcss-loader/node_modules/postcss/lib/container.js:135:18
[HBuilder] 15:28:39.304 at Rule.each (/Applications/HBuilderX.app/Contents/HBuilderX/plugins/uniapp-cli/node_modules/postcss-loader/node_modules/postcss/lib/container.js:101:16)
[HBuilder] 15:28:39.321 at Rule.walk (/Applications/HBuilderX.app/Contents/HBuilderX/plugins/uniapp-cli/node_modules/postcss-loader/node_modules/postcss/lib/container.js:131:17)
[HBuilder] 15:28:39.339 at /Applications/HBuilderX.app/Contents/HBuilderX/plugins/uniapp-cli/node_modules/postcss-loader/node_modules/postcss/lib/container.js:148:24
[HBuilder] 15:28:39.353 at Root.each (/Applications/HBuilderX.app/Contents/HBuilderX/plugins/uniapp-cli/node_modules/postcss-loader/node_modules/postcss/lib/container.js:101:16)
[HBuilder] 15:28:39.372 at Root.walk (/Applications/HBuilderX.app/Contents/HBuilderX/plugins/uniapp-cli/node_modules/postcss-loader/node_modules/postcss/lib/container.js:131:17)
[HBuilder] 15:28:39.391 at Root.walkDecls (/Applications/HBuilderX.app/Contents/HBuilderX/plugins/uniapp-cli/node_modules/postcss-loader/node_modules/postcss/lib/container.js:188:19)
[HBuilder] 15:28:39.405 at css (/Applications/HBuilderX.app/Contents/HBuilderX/plugins/uniapp-cli/node_modules/postcss-minify-gradients/dist/index.js:178:23)
[HBuilder] 15:28:39.422 DONE Build complete.
[HBuilder] 15:28:39.439 项目 'APP' 编译成功。
[HBuilder] 15:28:39.457 ERROR Build failed with errors.
[HBuilder] 15:28:39.474 项目 'APP'导出失败

  • 1***@qq.com

    我们的问题原因找到了

    background: linear-gradient(to bottm);

    这个bottom单词写错了,然后就报错,但是报错的地方不对,也没有发现其他异常

    2020-09-11 13:22

xcjack

xcjack (作者) - 后端工程师

这个问题结一下贴,原因是CSS 的渐变背景色,现在改成新的写法,旧的写法会报这个错误。

该问题目前已经被锁定, 无法添加新回复