vue.js - 抛出新错误 ('Cyclic dependency' + nodeRep)

标签 vue.js vuex

我在我的应用程序中使用了很多图表,我想尽可能地处理 vuex 存储中的所有图表颜色。我使用下面的代码来实现这一点。

store.js

import Vue from 'vue'
import Vuex from 'vuex'

// modules
import settings from './modules/settings';

Vue.use(Vuex);

export const store = new Vuex.Store({
    modules: {
        settings
    }
})

chart-config.js

/**
* Change all chart colors
*/
import { store } from "../store/store";

const { primary, warning, error, info, success } = store.getters.chartColors;

export const ChartConfig = {
   color: {
      'primary': primary,
      'warning': warning,
      'danger': error,
      'success': success,
      'info': info,
      'white': '#fff',
      'lightGrey': '#E8ECEE'
   },
   lineChartAxesColor: '#E9ECEF',
   legendFontColor: '#AAAEB3', // only works on react chart js 2
   chartGridColor: '#EAEAEA',
   axesColor: '#657786',
   shadowColor: 'rgba(0,0,0,0.3)'
}

文件夹结构:

src
 -components
 -constants
   --chart-config.js
 -store
   --store.js
 -views
 App.vue
 main.js

每当我尝试运行 npm run dev 命令时,我都会遇到这种类型的错误

95% emitting HtmlWebpackPlugin/media/iron/631dbce0-858c-4a8c-bef4- 
a01a6a92507f/shubham/work/dev/vue/myapp/node_modules/toposort/index.js:35 
throw new Error('Cyclic dependency' + nodeRep)

最佳答案

更新 2018-07-31

几天前,我在使用 @vue/cli (Vue CLI 3) 创建的 vue 应用程序时遇到了同样的问题。但是they fixed it最近。

旧答案

我的解决方案是创建 vue.config.js在项目根目录(package.json 旁边)resets chunksSortMode of the package html-webpack-plugin :

vue.config.js

module.exports = {
  chainWebpack: config => {
    config
      .plugin('html')
      .tap(args => {
        args[0].chunksSortMode = 'none'

        return args
      })
  }
}

关于vue.js - 抛出新错误 ('Cyclic dependency' + nodeRep),我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/51113525/

相关文章:

javascript - Vue.js - "Bind" Bootstrap 模态到 Vue 模型

javascript - 在 Vuex 模块中进行继承的方法

javascript - [Vue 警告] : Error in render: "TypeError: Converting circular structure to JSON

vue.js - 如何将完成的 nuxt.js 应用程序部署到网络服务器?

javascript - 需要 VueJS Getter 仅以数组形式返回最后一个 JSON 属性的所有值

javascript - 如何在 .vue 文件的 <script> 部分的父组件中处理通过 this.$emit 发出的自定义子事件?

vue.js - v-navigation-drawer 在窗口调整大小时陷入失控循环

unit-testing - Vue Test Utils/Jest - 如何测试类方法是否在组件方法中被调用

javascript - 未向导出的模块提供此上下文

javascript - vue loader 一个扩展的不同加载器