dcloudio / uni-app

A cross-platform framework using Vue.js
https://uniapp.dcloud.io
Apache License 2.0
40.15k stars 3.63k forks source link

reportJSException >>>> exception function:createInstanceContext, exception:white screen cause create instanceContext failed,check js stack ->Exception: SyntaxError: Unexpected token '...'. Expected a property name. #1816

Closed d1y closed 4 years ago

d1y commented 4 years ago

问题描述

论坛里问了下: https://ask.dcloud.net.cn/question/99678

  1. 我不太清楚是哪个模块造成了这个问题
  2. 这是个 ts 项目, 还引入了一些 js 模块

复现步骤

16:33:40.438 正在建立手机连接...
16:33:41.210 手机端调试基座版本号为2.7.9,版本号相同,跳过基座更新
16:33:41.293 正在同步手机端程序文件...
16:33:42.380 同步手机端程序文件完成
16:33:43.506 正在启动HBuilder调试基座...
16:33:45.655 应用【x】已启动...
16:33:53.174 reportJSException >>>> exception function:createInstanceContext, exception:white screen cause create instanceContext failed,check js stack ->Exception: SyntaxError: Unexpected token '...'. Expected a property name.
16:33:53.201 at weex createInstanceContext:36548
16:33:53.239 getTemplateInfo== template md5 9b1b40d6c0c8fc25477745fa1c91a2cf length 2139784 base64 md5 mxtA1sDI/CVHd0X6HJGizw== response header {"templateSourceBase64MD5":["mxtA1sDI/CVHd0X6HJGizw=="],"templateSourceMD5":["9b1b40d6c0c8fc25477745fa1c91a2cf"]}

系统信息:

yarn run v1.22.4
$ node node_modules/@dcloudio/vue-cli-plugin-uni/commands/info.js
uni-app v2.7.9
uni-app cli v2.0.0-27920200527001

Environment Info:

  System:
    OS: macOS 10.15.5
    CPU: (4) x64 Intel(R) Core(TM) i5-5350U CPU @ 1.80GHz
  Binaries:
    Node: 12.3.0 - /var/folders/fx/t5bzx1kx5kb4t44_d9hcsmy40000gn/T/yarn--1592815153507-0.1160152977956801/node
    Yarn: 1.22.4 - /var/folders/fx/t5bzx1kx5kb4t44_d9hcsmy40000gn/T/yarn--1592815153507-0.1160152977956801/yarn
    npm: 6.13.0 - /usr/local/bin/npm
  Browsers:
    Chrome: 83.0.4103.106
    Firefox: Not Found
    Safari: 13.1.1
  npmPackages:
    @dcloudio/types: * => 1.0.2 
    @dcloudio/uni-app-plus: ^2.0.0-27520200518001 => 2.0.0-27920200527001 
    @dcloudio/uni-app-plus-nvue:  0.0.1 
    @dcloudio/uni-app-plus-nvue-v8:  0.0.1 
    @dcloudio/uni-automator: ^2.0.0-27520200518001 => 2.0.0-27920200527001 
    @dcloudio/uni-cli-shared: ^2.0.0-27520200518001 => 2.0.0-27920200527001 
    @dcloudio/uni-h5: ^2.0.0-27520200518001 => 2.0.0-27920200527001 
    @dcloudio/uni-helper-json: * => 1.0.5 
    @dcloudio/uni-migration: ^2.0.0-27520200518001 => 2.0.0-27920200527001 
    @dcloudio/uni-mp-alipay: ^2.0.0-27520200518001 => 2.0.0-27920200527001 
    @dcloudio/uni-mp-baidu: ^2.0.0-27520200518001 => 2.0.0-27920200527001 
    @dcloudio/uni-mp-qq: ^2.0.0-27520200518001 => 2.0.0-27920200527001 
    @dcloudio/uni-mp-toutiao: ^2.0.0-27520200518001 => 2.0.0-27920200527001 
    @dcloudio/uni-mp-weixin: ^2.0.0-27520200518001 => 2.0.0-27920200527001 
    @dcloudio/uni-quickapp-native: ^2.0.0-27520200518001 => 2.0.0-27920200527001 
    @dcloudio/uni-quickapp-webview: ^2.0.0-27520200518001 => 2.0.0-27920200527001 
    @dcloudio/uni-stat: ^2.0.0-27520200518001 => 2.0.0-27920200527001 
    @dcloudio/uni-template-compiler: ^2.0.0-27520200518001 => 2.0.0-27920200527001 
    @dcloudio/vue-cli-plugin-hbuilderx: ^2.0.0-27520200518001 => 2.0.0-27920200527001 
    @dcloudio/vue-cli-plugin-uni: ^2.0.0-27520200518001 => 2.0.0-27920200527001 
    @dcloudio/vue-cli-plugin-uni-optimize: ^2.0.0-27520200518001 => 2.0.0-27920200527001 
    @dcloudio/webpack-uni-mp-loader: ^2.0.0-27520200518001 => 2.0.0-27920200527001 
    @dcloudio/webpack-uni-nvue-loader:  0.0.1 
    @dcloudio/webpack-uni-pages-loader: ^2.0.0-27520200518001 => 2.0.0-27920200527001 
    @hap-toolkit/dsl-vue:  0.6.13 
    @vue/babel-helper-vue-jsx-merge-props:  1.0.0 
    @vue/babel-plugin-transform-vue-jsx:  1.1.2 
    @vue/babel-preset-app:  4.4.4 
    @vue/babel-preset-jsx:  1.1.2 
    @vue/babel-sugar-functional-vue:  1.1.2 
    @vue/babel-sugar-inject-h:  1.1.2 
    @vue/babel-sugar-v-model:  1.1.2 
    @vue/babel-sugar-v-on:  1.1.2 
    @vue/cli-overlay:  4.4.4 
    @vue/cli-plugin-babel: ^4.3.0 => 4.4.4 
    @vue/cli-plugin-router:  4.4.4 
    @vue/cli-plugin-typescript: * => 4.4.4 
    @vue/cli-plugin-vuex:  4.4.4 
    @vue/cli-service: ^4.3.0 => 4.4.4 
    @vue/cli-shared-utils:  4.4.4 
    @vue/component-compiler-utils:  3.1.2 (3.1.2)
    @vue/preload-webpack-plugin:  1.1.1 
    @vue/web-component-wrapper:  1.2.0 
    mpvue-page-factory:  1.0.1 
    mpvue-template-compiler:  1.0.13 
    uni-h5-vue:  2.6.10 
    uni-mp-vue:  2.6.10 
    vue: ^2.6.11 => 2.6.11 
    vue-class-component: ^6.3.2 => 6.3.2 (7.2.3)
    vue-hot-reload-api:  2.3.4 
    vue-loader:  15.9.2 (15.9.2)
    vue-property-decorator: ^8.0.0 => 8.5.1 
    vue-router:  3.0.1 
    vue-style-loader:  4.1.2 
    vue-template-compiler: ^2.6.11 => 2.6.11 
    vue-template-es2015-compiler:  1.9.1 
    vuex: ^3.2.0 => 3.4.0 
    vuex-persistedstate: ^3.0.1 => 3.0.1 
  npmGlobalPackages:
    @vue/cli: 4.4.4

✨  Done in 14.75s.

麻烦解答下, 谢谢哈🙈

dcloudhdx commented 4 years ago

三方 npm 包使用了不支持的扩展运算符 "...",Android 上使用的 jscore 对 "..." 支持不完善

解决方案 配置 babel 显式转译 将 package.json 依赖的三方库加到 vue.config.js 节点 transpileDependencies: ['模块名称',...]

暂时没有办法定位具体文件,可通过删除代码或在项目中搜索,展开对象的用法

(function() {
    const a = {
        a: 1,
        b: 2
    }
    console.log({
        ...a
    })
})();
d1y commented 4 years ago

麻烦问下, 造成这种错误只是第三方包 npm 包吗? 我本地也用了 ... 展开运算符

谢谢

d1y commented 4 years ago

我将可疑的几个 npm 包丢在了 vue.config.jstranspileDependencies

然而还是报错, 我生成了本地的打包app资源, 然后搜索 ..., 结果

image

代码片段(app-service.js): https://note.ms/ijbi

有点迷了, 貌似加 transpileDependencies 好像没有成功

不过特别奇怪的是, 我用调试服务, 就可以运行不报错了

image.png

fxy060608 commented 4 years ago

1.把normalize-url也加到transpileDependencies里边 2.调试期间,js代码运行在pc端,与真机运行环境不同

d1y commented 4 years ago

已解决问题, 感谢各位

BigFly2333 commented 3 years ago

已解决问题, 感谢各位

请问下是怎么解决的,我这边线上也出现了这个问题,在ios10和ios11上

jorschach-g commented 3 years ago

已解决问题, 感谢各位

同问,如果有方案烦请大概做一个描述... 谢谢了。

inoryxun commented 2 years ago

一直都是很正常的,今天是在没有任何更改第三方包的情况下,突然报这个错误了