Ошибка в подключениях. Field 'browser' doesn't contain a valid alias configuration

введите сюда описание изображения

Подскажите пожалуйста плз. Когда пытаюсь подключить F:\test\src\pages\main\index.ts в F:\test\src\pages\app\index.ts выходит ошибка, не понимаю почему. Какая-то проблема в подключениях.

ERROR in ./pages/app/index.ts 1:0-31
Module not found: Error: Can't resolve '../main' in 'F:\test\src\pages\app'
resolve '../main' in 'F:\test\src\pages\app'
  using description file: F:\test\package.json (relative path: ./src/pages/app)
    Field 'browser' doesn't contain a valid alias configuration
    using description file: F:\test\package.json (relative path: ./src/pages/main)
      no extension
        Field 'browser' doesn't contain a valid alias configuration
        F:\test\src\pages\main is not a file
      .js
        Field 'browser' doesn't contain a valid alias configuration
        F:\test\src\pages\main.js doesn't exist
      .json
        Field 'browser' doesn't contain a valid alias configuration
        F:\test\src\pages\main.json doesn't exist
      .wasm
        Field 'browser' doesn't contain a valid alias configuration
        F:\test\src\pages\main.wasm doesn't exist
      as directory
        existing directory F:\test\src\pages\main
          using description file: F:\test\package.json (relative path: ./src/pages/main)
            using path: F:\test\src\pages\main\index
              using description file: F:\test\package.json (relative path: ./src/pages/main/index)
                no extension
                  Field 'browser' doesn't contain a valid alias configuration
                  F:\test\src\pages\main\index doesn't exist
                .js
                  Field 'browser' doesn't contain a valid alias configuration
                  F:\test\src\pages\main\index.js doesn't exist
                .json
                  Field 'browser' doesn't contain a valid alias configuration
                  F:\test\src\pages\main\index.json doesn't exist
                .wasm
                  Field 'browser' doesn't contain a valid alias configuration
                  F:\test\src\pages\main\index.wasm doesn't exist
 @ ./index.js 12:0-39 13:12-15

webpack 5.73.0 compiled with 1 error in 4649 ms

webpack.config.js

const path = require("path")
const HTMLWebpackPlugin = require("html-webpack-plugin");
const { CleanWebpackPlugin } = require("clean-webpack-plugin");
const ESLintPlugin = require("eslint-webpack-plugin");
module.exports = {
  context: path.resolve(__dirname, "src"),
  mode: "development",
  entry: {
    main: "./index.js"
  },
  output: {
    filename: "[name].[contenthash].bundle.js",
    path: path.resolve(__dirname, "dist"),
  },
  resolve: {
    alias: {
      "@npms": path.resolve(__dirname, "_help"),
      "@": path.resolve(__dirname, "src"),
    },
  },
  plugins: [
    new HTMLWebpackPlugin({
      template: "./index.html",
    }),
    new CleanWebpackPlugin(),
    new ESLintPlugin({
      extensions: ["ts"],
    }),
  ],
  module: {
    rules: [
      {
        test: /\.(sa|sc|c)ss$/,
        use: ["style-loader", "css-loader", "sass-loader"],
      },
      {
        test: /\.(png|svg|jpg|jpeg|gif|txt)$/i,
        type: "asset/resource",
      },
      {
        test: /\.(ts|tsx)$/i,
        exclude: /node_modules/,
        include: path.resolve(__dirname, "src"),
        use: ["ts-loader"],
      },
    ],
  },
};

F:\test\src\pages\main\index.ts

const MainPage:string = '123'
export default MainPage

F:\test\src\pages\app\index.ts

import MainPage from "../main";
const App:string = MainPage
export default App

F:\test\src\index.js

import App from './pages/app/index.ts';
console.log(App)

Ответы (0 шт):