mpvue小程序启动报错:TypeError: Cannot read property 'platform' of undefined

错误:

$ yarn dev
yarn run v1.19.1
$ node build/dev-server.js
/Users/mahaiqiang/git/redcreation/customplatform/customApplet/node_modules/mpvue-template-compiler/build.js:5812
    switch(fileExt.platform) {
                   ^

TypeError: Cannot read property 'platform' of undefined
    at Object.compileToWxml (/Users/mahaiqiang/git/redcreation/customplatform/customApplet/node_modules/mpvue-template-compiler/build.js:5812:20)
    at genComponentWxml (/Users/mahaiqiang/git/redcreation/customplatform/customApplet/node_modules/mpvue-loader/lib/mp-compiler/index.js:45:75)
    at Timeout.createWxml [as _onTimeout] (/Users/mahaiqiang/git/redcreation/customplatform/customApplet/node_modules/mpvue-loader/lib/mp-compiler/index.js:92:19)
    at listOnTimeout (timers.js:329:17)
    at processTimers (timers.js:271:5)
error Command failed with exit code 1.
info Visit https://yarnpkg.com/en/docs/cli/run for documentation about this command.

依赖版本:

 "mpvue-entry": "^1.4.7",
    "mpvue-loader": "1.2.2",
    "mpvue-template-compiler": "^1.0.11",
    "mpvue-webpack-target": "^1.0.0",

node版本

$ node -v    
v11.10.1

解决

参考方案:

  1. https://github.com/Meituan-Dianping/mpvue/issues/1371
  2. https://github.com/F-loat/mpvue-quickstart/commit/eb4ac7ec8ba7d4dc4742e3f9e382b1762144cd53

修改

  • 升级mpvue版本
"mpvue-loader": "1.2.2"
  • 修改vue-loader.conf.js
    module.exports增加以下配置
  fileExt: {
    template: 'wxml',
    script: 'js',
    style: 'wxss',
    platform: 'wx'
  }
  • 修改webpack.base.conf.js
//options: { checkMPEntry: true }
// 替换为
options: Object.assign({ checkMPEntry: true }, vueLoaderConfig)

你可能感兴趣的:(mpvue小程序启动报错:TypeError: Cannot read property 'platform' of undefined)