Module not found: Error: Can't resolve existing module
Module not found: Error: Can't resolve existing module
我正在从同一个包中导入两个模块。
import { RowSelection } from "gridjs/plugins/selection";
import { Grid } from "gridjs";
我可以在 VSCode 中访问 RowSelection(例如通过转到定义)就好了。 Intellisense 也工作正常。因此模块定义似乎没问题。
我的问题是 webpack 对 Grid 成功但对 RowSelection 失败并显示以下错误消息:
Module not found: Error: Can't resolve 'gridjs/plugins/selection' in 'C:\workspace\src'
错误信息也是正确的。该模块肯定不存在于上述路径中。它在'../node_modules/gridjs/plugins/selection'.
我不明白,为什么它在节点模块目录中的搜索方式与在 Grid 中的搜索方式不同。
为什么 RowSelection 的解析方式与 Grid 的解析方式不同?我该如何解决这个问题?
这是我的 webpack 配置:
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",
},
],
},
],
},
});
唯一想到的是您没有在基本 webpack 配置中包含 .tsx 文件和 .ts 文件?线索是rowSelection的源文件是rowSelection.tsx(错误),gridjs是gridjs.ts(没有错误)。这可能解释了错误消息,因为 rowSeletion.tsx 没有被 webpack 转译,因此无法在 src 文件夹中找到。
显然这不是我的配置问题,但已被报告为 gridjs (https://github.com/grid-js/gridjs/issues/969)
的问题
我正在从同一个包中导入两个模块。
import { RowSelection } from "gridjs/plugins/selection";
import { Grid } from "gridjs";
我可以在 VSCode 中访问 RowSelection(例如通过转到定义)就好了。 Intellisense 也工作正常。因此模块定义似乎没问题。
我的问题是 webpack 对 Grid 成功但对 RowSelection 失败并显示以下错误消息:
Module not found: Error: Can't resolve 'gridjs/plugins/selection' in 'C:\workspace\src'
错误信息也是正确的。该模块肯定不存在于上述路径中。它在'../node_modules/gridjs/plugins/selection'.
我不明白,为什么它在节点模块目录中的搜索方式与在 Grid 中的搜索方式不同。
为什么 RowSelection 的解析方式与 Grid 的解析方式不同?我该如何解决这个问题?
这是我的 webpack 配置:
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",
},
],
},
],
},
});
唯一想到的是您没有在基本 webpack 配置中包含 .tsx 文件和 .ts 文件?线索是rowSelection的源文件是rowSelection.tsx(错误),gridjs是gridjs.ts(没有错误)。这可能解释了错误消息,因为 rowSeletion.tsx 没有被 webpack 转译,因此无法在 src 文件夹中找到。
显然这不是我的配置问题,但已被报告为 gridjs (https://github.com/grid-js/gridjs/issues/969)
的问题