Search code examples
javascriptwebpackgridjs

Module not found: Error: Can't resolve existing module


I am importing two modules from the same package.

import { RowSelection } from "gridjs/plugins/selection";
import { Grid } from "gridjs";

I can access RowSelection in VSCode (e.g. by go to definition) just fine. Intellisense is working fine too. Therefore the module definition seems okay.

My issue is that webpack is successful for Grid but fails for RowSelection with the following error message:

Module not found: Error: Can't resolve 'gridjs/plugins/selection' in 'C:\workspace\src' 

The error message is correct as well. The module definitely does not exist in the mentioned path. It is in '../node_modules/gridjs/plugins/selection'.

I don't understand, why it is not searching in the node modules directory the same way as it is doing for Grid though.

Why is RowSelection resolved differently than Grid and what can I do to fix this issue?

This is my webpack configuration:

const webpackMerge = require("webpack-merge");
const baseDashboardConfig =
  require("@splunk/webpack-configs/dashboard.config").default;
const baseConfig = require("@splunk/webpack-configs").default;

module.exports = webpackMerge(baseConfig, {
  entry: "./src/details_dialog.js",
  output: {
    path: __dirname,
    filename: "details_dialog.js",
  },
  module: {
    rules: [
      {
        test: /\.css$/,
        //exclude: [/node_modules/],
        use: [
          {
            loader: "style-loader",
          },
          {
            loader: "css-loader",
          },
        ],
      },
    ],
  },
});

Solution

  • Apparently this is not in issue with my configuration but has been reported as an issue with gridjs (https://github.com/grid-js/gridjs/issues/969)