Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

升级 1.2.12 后小程序编译报错 #2098

Closed
AvailCat opened this issue Jan 31, 2019 · 6 comments
Closed

升级 1.2.12 后小程序编译报错 #2098

AvailCat opened this issue Jan 31, 2019 · 6 comments

Comments

@AvailCat
Copy link

问题描述
从 1.2.8 升级到 1.2.12 后小程序编译时会出现 "压缩错误"

复现步骤

  1. 升级 1.2.12

涉及到的文件较多,不便全部提供;参考报错信息,如有需要再提供

期望行为
无报错

报错信息

错误  压缩错误  文件D:\WorkSpace\ETUMiniApp\ETUSpace\src\utils\wechat.js
{ SyntaxError: Unexpected token: name (Taro)
    at JS_Parse_Error.get (eval at <anonymous> (D:\WorkSpace\ETUMiniApp\ETUSpace\node_modules\uglify-js\tools\node.js:20:1), <anonymous>:71:23)
    at formatError (internal/util/inspect.js:865:16)
    at formatRaw (internal/util/inspect.js:648:14)
    at formatValue (internal/util/inspect.js:539:10)
    at inspect (internal/util/inspect.js:196:10)
    at Object.formatWithOptions (util.js:84:12)
    at Console.(anonymous function) (internal/console/constructor.js:274:15)
    at Console.log (internal/console/constructor.js:283:59)
    at recursiveRequire (D:\WorkSpace\ETUMiniApp\ETUSpace\node_modules\@tarojs\cli\src\util\resolve_npm_files.js:210:19)
    at resolveNpmFilesPath (D:\WorkSpace\ETUMiniApp\ETUSpace\node_modules\@tarojs\cli\src\util\resolve_npm_files.js:72:5)
  message: 'Unexpected token: name (Taro)',
  filename: '0',
  line: 1,
  col: 7,
  pos: 7 }
拷贝  NPM文件   D:/WorkSpace/ETUMiniApp/ETUSpace/src/utils/wechat.js
错误  压缩错误  文件D:\WorkSpace\ETUMiniApp\ETUSpace\src\utils\request.js
{ SyntaxError: Unexpected token: name (Taro)
    at JS_Parse_Error.get (eval at <anonymous> (D:\WorkSpace\ETUMiniApp\ETUSpace\node_modules\uglify-js\tools\node.js:20:1), <anonymous>:71:23)
    at formatError (internal/util/inspect.js:865:16)
    at formatRaw (internal/util/inspect.js:648:14)
    at formatValue (internal/util/inspect.js:539:10)
    at inspect (internal/util/inspect.js:196:10)
    at Object.formatWithOptions (util.js:84:12)
    at Console.(anonymous function) (internal/console/constructor.js:274:15)
    at Console.log (internal/console/constructor.js:283:59)
    at recursiveRequire (D:\WorkSpace\ETUMiniApp\ETUSpace\node_modules\@tarojs\cli\src\util\resolve_npm_files.js:210:19)
    at resolveNpmFilesPath (D:\WorkSpace\ETUMiniApp\ETUSpace\node_modules\@tarojs\cli\src\util\resolve_npm_files.js:72:5)
  message: 'Unexpected token: name (Taro)',
  filename: '0',
  line: 1,
  col: 7,
  pos: 7 }
拷贝  NPM文件   D:/WorkSpace/ETUMiniApp/ETUSpace/src/utils/request.js
错误  压缩错误  文件D:\WorkSpace\ETUMiniApp\ETUSpace\src\config\API.js
{ SyntaxError: Unexpected token: keyword (const)
    at JS_Parse_Error.get (eval at <anonymous> (D:\WorkSpace\ETUMiniApp\ETUSpace\node_modules\uglify-js\tools\node.js:20:1), <anonymous>:71:23)
    at formatError (internal/util/inspect.js:865:16)
    at formatRaw (internal/util/inspect.js:648:14)
    at formatValue (internal/util/inspect.js:539:10)
    at inspect (internal/util/inspect.js:196:10)
    at Object.formatWithOptions (util.js:84:12)
    at Console.(anonymous function) (internal/console/constructor.js:274:15)
    at Console.log (internal/console/constructor.js:283:59)
    at recursiveRequire (D:\WorkSpace\ETUMiniApp\ETUSpace\node_modules\@tarojs\cli\src\util\resolve_npm_files.js:210:19)
    at resolveNpmFilesPath (D:\WorkSpace\ETUMiniApp\ETUSpace\node_modules\@tarojs\cli\src\util\resolve_npm_files.js:72:5)
  message: 'Unexpected token: keyword (const)',
  filename: '0',
  line: 1,
  col: 0,
  pos: 0 }
拷贝  NPM文件   D:/WorkSpace/ETUMiniApp/ETUSpace/src/config/API.js
编译  页面文件  src/pages/taggedWorks/index
错误  压缩错误  文件D:\WorkSpace\ETUMiniApp\ETUSpace\src\config\pages.js
{ SyntaxError: Unexpected token: keyword (default)
    at JS_Parse_Error.get (eval at <anonymous> (D:\WorkSpace\ETUMiniApp\ETUSpace\node_modules\uglify-js\tools\node.js:20:1), <anonymous>:71:23)
    at formatError (internal/util/inspect.js:865:16)
    at formatRaw (internal/util/inspect.js:648:14)
    at formatValue (internal/util/inspect.js:539:10)
    at inspect (internal/util/inspect.js:196:10)
    at Object.formatWithOptions (util.js:84:12)
    at Console.(anonymous function) (internal/console/constructor.js:274:15)
    at Console.log (internal/console/constructor.js:283:59)
    at recursiveRequire (D:\WorkSpace\ETUMiniApp\ETUSpace\node_modules\@tarojs\cli\src\util\resolve_npm_files.js:210:19)
    at resolveNpmFilesPath (D:\WorkSpace\ETUMiniApp\ETUSpace\node_modules\@tarojs\cli\src\util\resolve_npm_files.js:72:5)
  message: 'Unexpected token: keyword (default)',
  filename: '0',
  line: 8,
  col: 7,
  pos: 90 }
拷贝  NPM文件   D:/WorkSpace/ETUMiniApp/ETUSpace/src/config/pages.js
错误  压缩错误  文件D:\WorkSpace\ETUMiniApp\ETUSpace\src\components\hoc\Authorize.js
{ SyntaxError: Unexpected token: punc ({)
    at JS_Parse_Error.get (eval at <anonymous> (D:\WorkSpace\ETUMiniApp\ETUSpace\node_modules\uglify-js\tools\node.js:20:1), <anonymous>:71:23)
    at formatError (internal/util/inspect.js:865:16)
    at formatRaw (internal/util/inspect.js:648:14)
    at formatValue (internal/util/inspect.js:539:10)
    at inspect (internal/util/inspect.js:196:10)
    at Object.formatWithOptions (util.js:84:12)
    at Console.(anonymous function) (internal/console/constructor.js:274:15)
    at Console.log (internal/console/constructor.js:283:59)
    at recursiveRequire (D:\WorkSpace\ETUMiniApp\ETUSpace\node_modules\@tarojs\cli\src\util\resolve_npm_files.js:210:19)
    at resolveNpmFilesPath (D:\WorkSpace\ETUMiniApp\ETUSpace\node_modules\@tarojs\cli\src\util\resolve_npm_files.js:72:5)
  message: 'Unexpected token: punc ({)',
  filename: '0',
  line: 1,
  col: 7,
  pos: 7 }
拷贝  NPM文件   D:/WorkSpace/ETUMiniApp/ETUSpace/src/components/hoc/Authorize.js
错误  压缩错误  文件D:\WorkSpace\ETUMiniApp\ETUSpace\src\config\config.js
{ SyntaxError: Unexpected token: keyword (default)
    at JS_Parse_Error.get (eval at <anonymous> (D:\WorkSpace\ETUMiniApp\ETUSpace\node_modules\uglify-js\tools\node.js:20:1), <anonymous>:71:23)
    at formatError (internal/util/inspect.js:865:16)
    at formatRaw (internal/util/inspect.js:648:14)
    at formatValue (internal/util/inspect.js:539:10)
    at inspect (internal/util/inspect.js:196:10)
    at Object.formatWithOptions (util.js:84:12)
    at Console.(anonymous function) (internal/console/constructor.js:274:15)
    at Console.log (internal/console/constructor.js:283:59)
    at recursiveRequire (D:\WorkSpace\ETUMiniApp\ETUSpace\node_modules\@tarojs\cli\src\util\resolve_npm_files.js:210:19)
    at resolveNpmFilesPath (D:\WorkSpace\ETUMiniApp\ETUSpace\node_modules\@tarojs\cli\src\util\resolve_npm_files.js:72:5)
  message: 'Unexpected token: keyword (default)',
  filename: '0',
  line: 2,
  col: 7,
  pos: 51 }

系统信息

Taro CLI 1.2.12 environment info:
System:
OS: Windows 10
Binaries:
Node: 11.8.0 - ~\scoop\apps\nodejs\current\node.EXE
npm: 6.5.0 - ~\scoop\apps\nodejs\current\npm.CMD

补充信息
升级后编译时src目录内的文件会被修改,执行了一些没有配置过的自动格式化操作,还将 process.env.APP_ID 这样的环境变量替换为了 config/dev.js 中的字符串

@taro-bot
Copy link

taro-bot bot commented Jan 31, 2019

欢迎提交 Issue~

如果你提交的是 bug 报告,请务必遵循 Issue 模板的规范,尽量用简洁的语言描述你的问题,最好能提供一个稳定简单的复现。🙏🙏🙏

如果你的信息提供过于模糊或不足,或者已经其他 issue 已经存在相关内容,你的 issue 有可能会被关闭。

Good luck and happy coding~

@luckyadam
Copy link
Member

检查一下这几个文件有没有语法错误

@AvailCat
Copy link
Author

AvailCat commented Feb 1, 2019

很奇怪,没有做过任何修改,今天再次运行的时候就没有任何问题了

@AvailCat
Copy link
Author

@luckyadam
Issue #2175, PR #2175

@DuanShuaiShuai
Copy link

请问是什么情况 我也遇到类似的情况了 我是升级到1.2.13

@AvailCat
Copy link
Author

@DuanShuaiShuai 具体情况在 #2175 这里,但是已经在 1.2.13 修复了

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

3 participants