Why does router.beforeEach report an error as soon as it is added to main.js?

Why do I report an error as soon as I open the comments on beforeEach?

import Vue from "vue"
import App from "./App"
import ElementUI from "element-ui";
import VueLazyload from "vue-lazyload"
import Vuex from "./vuex/store"
import "./global.css"
import "element-ui/lib/theme-chalk/index.css";
import {createRouter} from "./router";
import "./assets/iconfont/iconfont.css"
import "babel-polyfill"
import  VueQuillEditor from "vue-quill-editor"
// require styles 
import {get,post,postUp,postLogin,patch,del,postdel,put,posttree,posttree1} from "./utils/https"
import {setCookie,delCookie,getCookie} from "./utils/cookie"
import md5 from "js-md5";
Vue.prototype.$md5 = md5;
Vue.prototype.$get = get
Vue.prototype.$post = post
Vue.prototype.$del = del
Vue.prototype.$put = put
Vue.prototype.$postLogin = postLogin
Vue.prototype.$postUp = postUp
Vue.prototype.$setCookie = setCookie
Vue.prototype.$posttree = posttree
Vue.prototype.$posttree1 = posttree1
Vue.prototype.$postdel = postdel


import "quill/dist/quill.core.css"
import "quill/dist/quill.snow.css"
import "quill/dist/quill.bubble.css"

Vue.use(VueQuillEditor)
Vue.use(VueLazyload)


const router = createRouter()

// router.beforeEach((to,from,next)=>{
//   if(to.meta.requireAuth){
//     if(getCookie("session")){
//       next()
//     }else {
//       next({
//         path:"/",
//         query:{redirect: to.fullPath}
//       })
//     }
//   }else {
//     next()
//   }
// }

Vue.use(Vuex)
Vue.config.productionTip = false


Vue.use(ElementUI);
Vue.use(VueLazyload, {
  loading: "./assets/mo.png",//
  listenEvents:["scroll","wheel","mousewheel","resize","animationend","transitionend","touchmove"], 
})

/* eslint-disable no-new */
new Vue({
  el: "-sharpapp",
  router,
  components: { App },
  template: "<App/>"
})


clipboard.png


is missing a closing parenthesis.

router.beforeEach ((from,to,next) = > {

})


you are missing a back bracket).

Menu