【问题标题】:ag-grid-vue module not found even though it's in node_modules未找到 ag-grid-vue 模块,即使它位于 node_modules 中
【发布时间】:2020-04-02 19:56:56
【问题描述】:

我正在按照 Vue.js AgGrid 入门指南一步一步进行操作:https://www.ag-grid.com/vuejs-grid/

添加<script> 部分并保存后,我收到以下错误:

ERROR  Failed to compile with 1 errors                              12:01:18 PM

This dependency was not found:

* ag-grid-vue in ./node_modules/cache-loader/dist/cjs.js??ref--12-0!./node_modules/babel-loader/lib!./node_modules/cache-loader/dist/cjs.js??ref--0-0!./node_modules/vue-loader/lib??vue-loader-options!./src/App.vue?vue&type=script&lang=js&

To install it, you can run: npm install --save ag-grid-vue
Type checking in progress...
No type errors found
Version: typescript 3.5.3
Time: 1125ms

问题是我已经安装了它,使用指南中的命令:

npm install --save ag-grid-community ag-grid-vue vue-property-decorator

我已经检查了 node_modules,一切似乎都在那里。 到目前为止,这是我在 App.vue 中的代码:

<template>
    <ag-grid-vue style="width: 500px; height: 500px;"
                 class="ag-theme-balham"
                 :columnDefs="columnDefs"
                 :rowData="rowData">
    </ag-grid-vue>
</template>

<style lang="scss">
  @import "../node_modules/ag-grid-community/dist/styles/ag-grid.css";
  @import "../node_modules/ag-grid-community/dist/styles/ag-theme-balham.css";
</style>

<script>
    import {AgGridVue} from "ag-grid-vue";

    export default {
        name: 'App',
        data() {
            return {
                columnDefs: null,
                rowData: null
            }
        },
        components: {
            AgGridVue
        },
        beforeMount() {
            this.columnDefs = [
                {headerName: 'Make', field: 'make'},
                {headerName: 'Model', field: 'model'},
                {headerName: 'Price', field: 'price'}
            ];

            this.rowData = [
                {make: 'Toyota', model: 'Celica', price: 35000},
                {make: 'Ford', model: 'Mondeo', price: 32000},
                {make: 'Porsche', model: 'Boxter', price: 72000}
            ];
        }
    }
</script>

知道发生了什么吗?如果重要的话,在 MacOS Catalina 上,并使用最新的 LTS 版本的 Node(今天早上刚刚下载)。我也尝试过卸载并重新安装节点(“完整”的方式也删除了所有隐藏的节点文件夹和东西,然后从站点重新安装)。

【问题讨论】:

    标签: javascript node.js vue.js ag-grid ag-grid-vue


    【解决方案1】:

    看起来 ag-grid 入门文档已过时。现在要安装的正确软件包基于模块。

    例如在package.json的依赖下:

    "@ag-grid-community/all-modules": "~22.1.0",
    "@ag-grid-community/client-side-row-model": "~22.1.0",
    "@ag-grid-community/core": "~22.1.0",
    "@ag-grid-community/csv-export": "~22.1.0",
    "@ag-grid-community/infinite-row-model": "~22.1.0",
    "@ag-grid-community/vue": "~22.1.0",
    "@ag-grid-enterprise/all-modules": "~22.1.0",
    

    然后在组件的&lt;script&gt;

    import {AgGridVue} from "@ag-grid-community/vue";
    import {AllCommunityModules} from '@ag-grid-community/all-modules';
    

    export default下的“数据”中:

    data() {
        return {
            columnDefs: null,
            rowData: null,
            modules: AllCommunityModules
        }
    },
    

    最后在&lt;template&gt;

    <template>
        <ag-grid-vue style="width: 500px; height: 500px;"
                      class="ag-theme-balham"
                     :columnDefs="columnDefs"
                     :rowData="rowData"
                     :modules="modules">
        </ag-grid-vue>
    </template>
    

    为此从https://www.ag-grid.com/javascript-grid-modules/#installing-ag-grid-modules 获得了很多帮助。他们真的需要更新他们的入门页面!

    【讨论】:

      猜你喜欢
      • 2019-07-26
      • 2022-06-26
      • 1970-01-01
      • 2021-05-27
      • 1970-01-01
      • 1970-01-01
      • 1970-01-01
      • 2019-05-24
      • 2017-10-24
      相关资源
      最近更新 更多