Имеется проект со структурой
/src
index.jsx
/.babelrc
/package.json
/webpack.js
index.jsx:
import React from 'react';
import ReactDOM from 'react-dom';
ReactDOM.render(
<h1>Hello, World</h1>,
document.getElementById('app')
);
.babelrc:
{
"presets": [
"@babel/preset-env",
"@babel/preset-react"
],
"plugins": [
[
"@babel/plugin-proposal-class-properties",
{
"loose": true
}
]
]
}
webpack.js:
const path = require('path');
module.exports = {
mode: process.env.mode,
entry: ['babel-polyfill', './src/index.jsx'],
output: {
path: path.resolve(__dirname, 'dist'),
filename: './bundle.js'
},
module: {
rules: [
{
test: /\.(js|jsx)$/,
exclude: /node_modules/,
use: {
loader: 'babel-loader',
options: {
presets: ['@babel/preset-env'],
}
}
},
]
},
};
package.json:
{
"name": "test-search",
"version": "0.0.1",
"license": "MIT",
"scripts": {
"run:dev": "webpack-cli serve",
"build:dev": "webpack"
},
"dependencies": {
"react": "^17.0.2",
"react-dom": "^17.0.2",
},
"devDependencies": {
"@babel/core": "^7.15.0",
"@babel/plugin-proposal-class-properties": "^7.14.5",
"@babel/preset-env": "^7.15.0",
"@babel/preset-react": "^7.14.5",
"babel": "^6.23.0",
"babel-loader": "^8.2.2",
"babel-polyfill": "^6.26.0",
"cross-env": "^7.0.3",
"path": "^0.12.7",
"webpack": "^5.11.1",
"webpack-cli": "^4.3.1",
"webpack-dev-server": "^3.11.2"
}
}
При попытке запустить проект командой webpack-cli serve
или webpack
в консоль падает ошибка:
Module not found: Error: Can't resolve './src' in 'search-test'
resolve './src' in 'search-test'
using description file: \package.json (relative path: .)
Field 'browser' doesn't contain a valid alias configuration
using description file: \package.json (relative path: ./src)
no extension
Field 'browser' doesn't contain a valid alias configuration
\src is not a file
.js
Field 'browser' doesn't contain a valid alias configuration
\src.js doesn't exist
.json
Field 'browser' doesn't contain a valid alias configuration
\src.json doesn't exist
.wasm
Field 'browser' doesn't contain a valid alias configuration
\src.wasm doesn't exist
as directory
existing directory \src
using description file: \package.json (relative path: ./src)
using path: D:\projects\search-test\src\index
using description file: \package.json (relative path: ./src/index)
no extension
Field 'browser' doesn't contain a valid alias configuration
\src\index doesn't exist
.js
Field 'browser' doesn't contain a valid alias configuration
\src\index.js doesn't exist
.json
Field 'browser' doesn't contain a valid alias configuration
\src\index.json doesn't exist
.wasm
Field 'browser' doesn't contain a valid alias configuration
\src\index.wasm doesn't exist
Как исправить данную ошибку или в какую сторону стоит копать?