[Vue warn]: Error in render: “TypeError: Cannot read property ‘match’ of undefined”

VuePress build报错:

[Vue warn]: Error in render: "TypeError: Cannot read property 'match' of undefined"
tip Apply plugin @vuepress/register-components (i.e. "@vuepress/plugin-register-components") ...
found iny plugin @vuepress/active-header-links (i.e. "@vuepress/plugin-active-header-links") ...
tip Apply plugin @vuepress/search (i.e. "@vuepress/plugin-search") ...
---> in @vuepress/nprogress (i.e. "@vuepress/plugin-nprogress") ...
       
         
           
             
               
[Vue warn]: Error in render: "TypeError: Cannot read property 'match' of undefined"

found in

---> 
       
         
           
             
               
[Vue warn]: Error in render: "TypeError: Cannot read property 'match' of undefined"

found in

---> 
       
         
           
             
               
[Vue warn]: Error in render: "TypeError: Cannot read property 'match' of undefined"

found in

---> 
       
         
           
             
               
[Vue warn]: Error in render: "TypeError: Cannot read property 'match' of undefined"

found in

---> 
       
         
           
             
               
error Error rendering /: false
undefined
error Error rendering /style/: false
undefined
error Error rendering /components/: false
undefined
error Error rendering /install/: false
undefined
error Error rendering /guide/: false
undefined
TypeError: Cannot read property 'match' of undefined
    at ensureExt (node_modules/@vuepress/theme-default/util/index.js:35:25)
    at Proxy.link (node_modules/@vuepress/theme-default/components/NavLink.vue:38:0)
    at Proxy.computedGetter (D:\BayConnect\svn\ZHJR\CSIP\branches\CSIP_SSS_Pv0.02_Av0.15_Bv0.03_Cv0.02_Dv0.02_WARNv0.04_20210128\src\html\CSIP-view-ui-project\document\node_modules\vue\dist\vue.runtime.common.dev.js:4831:15)
    at Proxy.isInternal (node_modules/@vuepress/theme-default/components/NavLink.vue:57:0)
    at Proxy.computedGetter (D:\BayConnect\svn\ZHJR\CSIP\branches\CSIP_SSS_Pv0.02_Av0.15_Bv0.03_Cv0.02_Dv0.02_WARNv0.04_20210128\src\html\CSIP-view-ui-project\document\node_modules\vue\dist\vue.runtime.common.dev.js:4831:15)
    at Proxy.NavLinkvue_type_template_id_cfa5183e_render (node_modules/@vuepress/theme-default/components/NavLink.vue?a0ba:1:89)
    at VueComponent.Vue._render (D:\BayConnect\svn\ZHJR\CSIP\branches\CSIP_SSS_Pv0.02_Av0.15_Bv0.03_Cv0.02_Dv0.02_WARNv0.04_20210128\src\html\CSIP-view-ui-project\document\node_modules\vue\dist\vue.runtime.common.dev.js:3538:22)
    at resolve (D:\BayConnect\svn\ZHJR\CSIP\branches\CSIP_SSS_Pv0.02_Av0.15_Bv0.03_Cv0.02_Dv0.02_WARNv0.04_20210128\src\html\CSIP-view-ui-project\document\node_modules\vue-server-renderer\build.dev.js:8415:27)
    at waitForServerPrefetch (D:\BayConnect\svn\ZHJR\CSIP\branches\CSIP_SSS_Pv0.02_Av0.15_Bv0.03_Cv0.02_Dv0.02_WARNv0.04_20210128\src\html\CSIP-view-ui-project\document\node_modules\vue-server-renderer\build.dev.js:8287:3)
    at renderComponentInner (D:\BayConnect\svn\ZHJR\CSIP\branches\CSIP_SSS_Pv0.02_Av0.15_Bv0.03_Cv0.02_Dv0.02_WARNv0.04_20210128\src\html\CSIP-view-ui-project\document\node_modules\vue-server-renderer\build.dev.js:8426:3)
    at renderComponent (D:\BayConnect\svn\ZHJR\CSIP\branches\CSIP_SSS_Pv0.02_Av0.15_Bv0.03_Cv0.02_Dv0.02_WARNv0.04_20210128\src\html\CSIP-view-ui-project\document\node_modules\vue-server-renderer\build.dev.js:8383:5)
    at RenderContext.renderNode (D:\BayConnect\svn\ZHJR\CSIP\branches\CSIP_SSS_Pv0.02_Av0.15_Bv0.03_Cv0.02_Dv0.02_WARNv0.04_20210128\src\html\CSIP-view-ui-project\document\node_modules\vue-server-renderer\build.dev.js:8294:5)
    at RenderContext.next (D:\BayConnect\svn\ZHJR\CSIP\branches\CSIP_SSS_Pv0.02_Av0.15_Bv0.03_Cv0.02_Dv0.02_WARNv0.04_20210128\src\html\CSIP-view-ui-project\document\node_modules\vue-server-renderer\build.dev.js:2598:23)
    at cachedWrite (D:\BayConnect\svn\ZHJR\CSIP\branches\CSIP_SSS_Pv0.02_Av0.15_Bv0.03_Cv0.02_Dv0.02_WARNv0.04_20210128\src\html\CSIP-view-ui-project\document\node_modules\vue-server-renderer\build.dev.js:2451:9)
    at renderStringNode$1 (D:\BayConnect\svn\ZHJR\CSIP\branches\CSIP_SSS_Pv0.02_Av0.15_Bv0.03_Cv0.02_Dv0.02_WARNv0.04_20210128\src\html\CSIP-view-ui-project\document\node_modules\vue-server-renderer\build.dev.js:8511:5)
    at RenderContext.renderNode (D:\BayConnect\svn\ZHJR\CSIP\branches\CSIP_SSS_Pv0.02_Av0.15_Bv0.03_Cv0.02_Dv0.02_WARNv0.04_20210128\src\html\CSIP-view-ui-project\document\node_modules\vue-server-renderer\build.dev.js:8292:5)
npm ERR! code ELIFECYCLE
npm ERR! errno 1
npm ERR! [email protected] build: `vuepress build docs`
npm ERR! Exit status 1
npm ERR!
npm ERR! Failed at the [email protected] build script.
npm ERR! This is probably not a problem with npm. There is likely additional logging output above.

npm ERR! A complete log of this run can be found in:
npm ERR!     C:\Users\dexu.xie\AppData\Roaming\npm-cache\_logs\2021-03-26T08_15_22_685Z-debug.log

那是由于有变量为空。

config.js文件:

const {nav, sidebar} = require('./libs/navSidebar.js')
module.exports = {
  title: 'CSIP前端开发使用文档',
  description: '常见的注意事项、组件的使用等。',
  themeConfig: {
    nav: nav,
    sidebar:sidebar
  }
}

navSidebar.js文件:

const nav = [{}]
const sidebar = [
  {
    title: "介绍",
    path: "/guide/"
  },
  {
    title: "安装",
    path: "/install/"
  },
  {
    title: "组件",
    path: "/components/"
  },
  {
    title: "样式",
    path: "/style/"
  }
]
module.exports = {
  nav,
  sidebar
}

那是由于 nav 变量为空:const nav = [{}],解决办法是为空的不用即可。

直接先把nav注释掉:

const {nav, sidebar} = require('./libs/navSidebar.js')
module.exports = {
  title: 'CSIP前端开发使用文档',
  description: '常见的注意事项、组件的使用等。',
  themeConfig: {
    // nav: nav,
    sidebar:sidebar
  }
}

发表回复