Vue.js 在Vue组件中使用导入会给出;RangeError:超过最大调用堆栈大小;建筑时

Vue.js 在Vue组件中使用导入会给出;RangeError:超过最大调用堆栈大小;建筑时,vue.js,Vue.js,在构建Vue项目时,出现以下错误: 编译错误失败,有1个错误 7:30:01 PM RangeError:超出最大调用堆栈大小 Array.join loader.js:228 Function.Module.\u findPath 内部/modules/cjs/loader.js:228:56 loader.js:578 Function.Module.\u解析文件名 内部/modules/cjs/loader.js:578:25 loader.js:507 Function.Module.

在构建Vue项目时,出现以下错误:

编译错误失败,有1个错误
7:30:01 PM RangeError:超出最大调用堆栈大小

  • Array.join

  • loader.js:228 Function.Module.\u findPath 内部/modules/cjs/loader.js:228:56

  • loader.js:578 Function.Module.\u解析文件名 内部/modules/cjs/loader.js:578:25

  • loader.js:507 Function.Module.\u load 内部/modules/cjs/loader.js:507:25

  • loader.js:637 Module.require 内部/modules/cjs/loader.js:637:17

  • helpers.js:22 内部/modules/cjs/helpers.js:22:18

  • 提取chunks.js:35 getNames [bidconnect重定义]/[@vue]/preload webpack plugin/src/lib/extract chunks.js:35:22

  • 提取chunks.js:44 getNames [bidconnect重定义]/[@vue]/preload webpack plugin/src/lib/extract chunks.js:44:21

  • 提取chunks.js:44 getNames [bidconnect重定义]/[@vue]/preload webpack plugin/src/lib/extract chunks.js:44:21

  • 提取chunks.js:44 getNames [bidconnect重定义]/[@vue]/preload webpack plugin/src/lib/extract chunks.js:44:21

  • 提取chunks.js:44 getNames [bidconnect重定义]/[@vue]/preload webpack plugin/src/lib/extract chunks.js:44:21

  • 提取chunks.js:44 getNames [bidconnect重定义]/[@vue]/preload webpack plugin/src/lib/extract chunks.js:44:21

  • 提取chunks.js:44 getNames [bidconnect重定义]/[@vue]/preload webpack plugin/src/lib/extract chunks.js:44:21

  • 提取chunks.js:44 getNames [bidconnect重定义]/[@vue]/preload webpack plugin/src/lib/extract chunks.js:44:21

  • 提取chunks.js:44 getNames [bidconnect重定义]/[@vue]/preload webpack plugin/src/lib/extract chunks.js:44:21

  • 提取chunks.js:44 getNames [bidconnect重定义]/[@vue]/preload webpack plugin/src/lib/extract chunks.js:44:21

  • 提取chunks.js:44 getNames [bidconnect重定义]/[@vue]/preload webpack plugin/src/lib/extract chunks.js:44:21

  • 提取chunks.js:44 getNames [bidconnect重定义]/[@vue]/preload webpack plugin/src/lib/extract chunks.js:44:21

  • 提取chunks.js:44 getNames [bidconnect重定义]/[@vue]/preload webpack plugin/src/lib/extract chunks.js:44:21

  • 提取chunks.js:44 getNames [bidconnect重定义]/[@vue]/preload webpack plugin/src/lib/extract chunks.js:44:21

  • 提取chunks.js:44 getNames [bidconnect重定义]/[@vue]/preload webpack plugin/src/lib/extract chunks.js:44:21

  • 提取chunks.js:44 getNames [bidconnect重定义]/[@vue]/preload webpack plugin/src/lib/extract chunks.js:44:21

    错误生成失败,出现错误。npm错误!代码ELIFECYCLE npm ERR! 错误1 npm错误!威斯特-admin@1.9.0生成:
    vue cli服务生成
    npm错误!退出状态1 npm错误!npm错误!失败 威斯特-admin@1.9.0构建脚本。npm错误!这可能不是个好主意 npm的问题。上面可能还有其他日志输出

我推断导入路由器的导入语句中存在问题。我通过将此声明添加到另一个组件并复制相同的错误来确认它

import { router } from "@router";
请告诉我如何解决这个问题

以下是文件夹路由器内部的index.js:

import Vue from 'vue'
import Router from 'vue-router'
import AppLayout from '../components/admin/AppLayout'
import AuthLayout from '../components/auth/AuthLayout'
import lazyLoading from './lazyLoading'

Vue.use(Router)

const demoRoutes = []
if (process.env.NODE_ENV === 'development') {
  const VueBook = require('vue-book')

  demoRoutes.push(
    VueBook.createRoute({
      requireContext: require.context('./..', true, /.demo.vue$/),
      path: '/demo',
    }),
    VueBook.createRoute({
      requireContext: require.context('./../components', true, /.vue$/),
      path: '/presentation',
    }),
  )

  Vue.use(VueBook.VueBookComponents)
}

const EmptyParentComponent = {
  template: '<router-view></router-view>',
}

const router = new Router({
  routes: [
    ...demoRoutes,
    {
      path: '*',
      redirect: { name: 'dashboard' },
    },
    {
      path: '/auth',
      component: AuthLayout,
      children: [
        {
          name: 'login',
          path: 'login',
          component: lazyLoading('auth/login/Login'),
        },
        {
          name: 'logout',
          path: 'logout',
          component: lazyLoading('auth/logout/Logout'),
        },
        {
          name: 'signup',
          path: 'signup',
          component: lazyLoading('auth/signup/Signup'),
        },
        {
          name: 'company',
          path: 'company',
          component: lazyLoading('auth/company/Company'),
        },
        {
          name: 'companycontact',
          path: 'companycontact',
          component: lazyLoading('auth/companycontact/Companycontact'),
        },
        {
          path: '',
          redirect: { name: 'login' },
        },
      ],
    },
  ],
})

router.beforeEach((to, from, next) => {
  if (to.matched.some(record => record.meta.requiresAuth)) {
    let user
    Vue.prototype.$Amplify.Auth.currentAuthenticatedUser().then((data) => {
      if (data && data.signInUserSession) {
        user = data
        next()
      }
    }).catch((e) => {
      console.log(e)
      next('/auth/login')
    })
    if (!user) {
      next()
    } else {
      next()
    }
  } else {
    next()
  }
})

export default router
从“Vue”导入Vue
从“vue路由器”导入路由器
从“../components/admin/AppLayout”导入AppLayout
从“../components/auth/AuthLayout”导入AuthLayout
从“/lazyLoading”导入lazyLoading
Vue.use(路由器)
常数demoRoutes=[]
if(process.env.NODE_env===‘development’){
const VueBook=require('vue-book')
推(
VueBook.createRoute({
requireContext:require.context('./..',true,/.demo.vue$/),
路径:'/demo',
}),
VueBook.createRoute({
requireContext:require.context('./../components',true,/.vue$/),
路径:'/presentation',
}),
)
Vue.use(VueBook.VueBookComponents)
}
常量EmptyParentComponent={
模板:“”,
}
const路由器=新路由器({
路线:[
…民主路线,
{
路径:'*',
重定向:{name:'dashboard'},
},
{
路径:'/auth',
组件:AuthLayout,
儿童:[
{
名称:'登录',
路径:“登录”,
组件:lazyLoading('auth/login/login'),
},
{
名称:“注销”,
路径:“注销”,
组件:lazyLoading('auth/logout/logout'),
},
{
姓名:'注册',
路径:'注册',
组件:lazyLoading('auth/signup/signup'),
},
{
名称:'公司',
路径:'公司',
组件:lazyLoading('auth/company/company'),
},
{
名称:'companycontact',
路径:“公司联系人”,
组件:lazyLoading('auth/companycontact/companycontact'),
},
{
路径:“”,
重定向:{name:'login'},
},
],
},
],
})
路由器.beforeach((到、从、下一个)=>{
if(to.matched.some(record=>record.meta.requireAuth)){
让用户
Vue.prototype.$Amplify.Auth.currentAuthenticatedUser()。然后((数据)=>{
if(数据和数据签名会话){
用户=数据
下一个()
}
}).catch((e)=>{
控制台日志(e)
下一步('/auth/login')
})
如果(!用户){
下一个()
}否则{
下一个()
}
}否则{
下一个()
}
})
导出默认路由器
以下是Logout.vue组件:

<template>
  <div class="logout">
  </div>
</template>

<script>
import { Auth } from 'aws-amplify'
import { AmplifyEventBus } from 'aws-amplify-vue';
import { store } from '@/store';
import { router } from '@/router';

export default {
  name: 'logout',

  data() {
    return {
      email: '',
      password: ''
      // signedIn: false
    }
  },

  created(){
    Auth.signOut()
        .then(
          data =>{
          this.$store.state.signedIn = !!data;
          alert("Logged out");
          this.$router.push('/auth/login');
        } )
        .catch(err => console.log(err));
  },

  }

</script>

<style lang="scss">
.login {

  @include media-breakpoint-down(md) {
    width: 100%;
    padding-right: 2rem;
    padding-left: 2rem;
    .down-container {
      display: none;
    }
  }

  h2 {
    text-align: center;
  }
  width: 21.375rem;

  .down-container {
    margin-top: 3.125rem;
  }
}
</style>

从“aws放大”导入{Auth}
从“aws amplify vue”导入{AmplifyEventBus};
从'@/store'导入{store};
从“@/router”导入{router};
导出默认值{
名称:“注销”,
数据(){