iqiyi/LiteApp

UnhandledPromiseRejectionWarning: TypeError: Cannot destructure property `username` of 'undefined' or 'null'.

pengwei1024 opened this issue · 2 comments

执行打包操作npm run-script build 报错如下:

[cli_argv] 
 { _: [], config: './app.json', env: 'prod', target: 'app' }
[cli_config] 
 { name: 'liteAppDemo',
  version: { business: '1.0', base: '1.2' },
  src: './src',
  res: './res',
  target: './dist',
  pages: [ { name: 'index', path: '/entry/index' } ],
  index: 'index',
  tabbar: { items: [ [Object] ] } }
/Users/pengwei/git/liteAppDemo/node_modules/liteapp-base/dist/base-app/1.2 /Users/pengwei/git/liteAppDemo/dist/base/1.2/package
[manifest] { pages: [ { name: 'index', path: '/pages/index/' } ],
  index: 'index',
  tabbar: { items: [ [Object] ] } }
[version business] { version: 
   { version: '1.0',
     base_version: '1.2',
     manifest_url: '/conf/manifest.json' },
  uri: '/Users/pengwei/git/liteAppDemo/dist/package/liteAppDemo/version' }
[version base] { version: { version: '1.2' },
  uri: '/Users/pengwei/git/liteAppDemo/dist/package/base/1.2/version' }
[webpackConfig] :  
 { entry: { index: '/Users/pengwei/git/liteAppDemo/src/entry/index' },
  output: 
   { path: '/Users/pengwei/git/liteAppDemo/dist/liteAppDemo/package',
     publicPath: '/',
     filename: 'pages/[name]/bundle.js' },
  module: { rules: [ [Object], [Object], [Object], [Object] ] },
  resolve: 
   { alias: { './res': '/Users/pengwei/git/liteAppDemo/res' },
     extensions: [ '.', '.js', '.jsx' ] },
  resolveLoader: 
   { modules: 
      [ '/Users/pengwei/git/liteAppDemo/node_modules/liteapp-cli/node_modules',
        'node_modules' ],
     extensions: [ '.', '.js', '.json' ],
     mainFields: [ 'loader', 'main' ] },
  plugins: 
   [ ExtractTextPlugin { filename: 'pages/[name]/bundle.css', id: 1, options: {} },
     { apply: [Function: apply] },
     UglifyJsPlugin { options: [Object], sourceMapsCache: WeakMap {} } ] }
[manifest] build success
[version] build success
[base-app 1.2] copied
[make bundle] finished
[zip build] finished
(node:3160) UnhandledPromiseRejectionWarning: TypeError: Cannot destructure property `username` of 'undefined' or 'null'.
    at res (/Users/pengwei/git/liteAppDemo/node_modules/liteapp-cli/src/deploy.js:30:73)
    at new Promise (<anonymous>)
    at Object.pushToServer (/Users/pengwei/git/liteAppDemo/node_modules/liteapp-cli/src/deploy.js:29:12)
    at <anonymous>
    at process._tickCallback (internal/process/next_tick.js:160:7)
(node:3160) 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: 3)
(node:3160) [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.

请问报错是什么原因呢? 直接运行是没有问题的

知道什么原因了,对Vue不是特别熟,

template: '<div><button @click="click">click</button><div>{{num}}</div></div>'

可能这样写被解析成网页了

这是由于在prod模式下会自动进行deploy操作(根据app.json内配置的服务器信息)。
我们对其进行了修正,使得只有在--deploy配置下才会触发,:D
升级liteapp-cli至0.0.2可解决此报错。
多谢反馈,谢谢!