0

As suggested by an answer to this question, the error

"unexpted token export"

is because the code given below is in es6 syntax but Node JS uses common JS module.

const SidebarMenu = require('./components/SidebarMenu.vue')

    export default {
      install (Vue) {
        Vue.component('sidebar-menu', SidebarMenu)
      }
    }

    export { SidebarMenu }

Please help me to convert it to commonJS module. I have tried module.exports as below

  const SidebarMenu = require('./components/SidebarMenu.vue')

  install = function (Vue) {
    Vue.component('sidebar-menu', SidebarMenu)
  }


module.exports = { SidebarMenu, install }

but it does not work either. I get an error that the component SidebarMenu was not found.

Ramesh Pareek
  • 1,601
  • 3
  • 30
  • 55
  • It is unclear what you need this export for (as in, what does the import expect). So far, it looks like an XY problem. Could you please explain what you're actually trying to do? Is your `SidebarMenu` supposed to be a Vue component? – tao Jun 26 '19 at 07:48

1 Answers1

0

Why are you exporting a require statement. You cant export a require statement. Is your function uses sidebarmenu , it will be exported with it. So no need to do it in your module.exports.

Just do module.exports{install}, without the sidebarmenu.

Kevin.a
  • 4,094
  • 8
  • 46
  • 82