I know this issue has been asked before , the solution was to create babel config file & webpack file but it still doesnt solve the issue
I was using a create react app and all this while it was working fine until I ran npm install. I am not too sure what caused it to break but now all it has is the appropriate loader error. I am NOT familiar with babel and webpack. So hopefully someone can shed some light here.
I have install the babel presets in package.json. Following is my package.json
{
"name": "frontend",
"version": "0.1.0",
"private": true,
"dependencies": {
"@ant-design/icons": "^4.7.0",
"@fortawesome/fontawesome-svg-core": "^6.1.1",
"@fortawesome/free-solid-svg-icons": "^6.1.1",
"@fortawesome/react-fontawesome": "^0.1.18",
"@hookform/resolvers": "^2.8.8",
"@reduxjs/toolkit": "^1.8.0",
"@testing-library/jest-dom": "^4.2.4",
"@testing-library/react": "^9.5.0",
"@testing-library/user-event": "^7.2.1",
"antd": "^4.19.1",
"axios": "^0.26.1",
"babel-preset-es2015": "^6.24.1",
"firebase": "^9.6.7",
"lodash.debounce": "^4.0.8",
"mdb-react-ui-kit": "^2.4.0",
"moment": "^2.29.3",
"otp-input-react": "^0.3.0",
"qs": "^6.10.5",
"react": "^17.0.2",
"react-dom": "^17.0.2",
"react-dropdown-tree-select": "^2.7.1",
"react-hook-form": "^7.27.1",
"react-moment": "^1.1.2",
"react-nestable": "^1.3.0",
"react-redux": "^7.2.6",
"react-router-dom": "^5.2.0",
"react-scripts": "^2.1.3",
"react-toastify": "^8.2.0",
"socket.io-client": "^4.4.1",
"yup": "^0.32.11"
},
"devDependencies": {
"@babel/core": "^7.0.0",
"@babel/plugin-proposal-class-properties": "^7.0.0",
"@babel/plugin-syntax-dynamic-import": "^7.0.0",
"@babel/preset-env": "^7.0.0",
"@babel/preset-react": "^7.0.0",
"babel-loader": "^8.0.1",
"css-loader": "^0.28.10",
"html-webpack-plugin": "^3.0.4",
"style-loader": "^0.19.1",
"webpack": "^4.0.0",
"webpack-cli": "^2.0.14",
"webpack-dev-server": "^3.0.0"
},
"scripts": {
"start": "PORT=4007 react-scripts start",
"build": "react-scripts build",
"test": "react-scripts test",
"eject": "react-scripts eject"
},
"eslintConfig": {
"extends": "react-app"
},
"browserslist": {
"production": [
">0.2%",
"not dead",
"not op_mini all"
],
"development": [
"last 1 chrome version",
"last 1 firefox version",
"last 1 safari version"
]
}
Following is my file structure
This is my .babelrc file
{
"presets": ["@babel/preset-env", "@babel/preset-react"],
"plugins": [
"@babel/plugin-syntax-dynamic-import",
"@babel/plugin-proposal-class-properties"
]
}
This is webpack.config.js file
const webpack = require("webpack");
const HtmlWebpackPlugin = require("html-webpack-plugin");
const port = process.env.PORT || 3000;
module.exports = {
mode: "development",
entry: "./src/index.js",
output: {
filename: "bundle.[hash].js",
},
devtool: "inline-source-map",
module: {
rules: [
{
test: /\.jsx?$/,
loader: "babel-loader",
exclude: /node_modules/,
query: {
presets: ["es2015"],
},
},
{
test: /\.css$/,
use: [
{
loader: "style-loader",
},
{
loader: "css-loader",
options: {
modules: true,
localsConvention: "camelCase",
sourceMap: true,
},
},
],
},
],
},
plugins: [
new HtmlWebpackPlugin({
template: "public/index.html",
favicon: "public/favicon.ico",
}),
],
devServer: {
host: "localhost",
port: port,
historyApiFallback: true,
open: true,
},
};
Thank you.
FOUND THE ANSWER Had to update react-scripts to ^5.0.0 and i removed babel.rc file and webpack config file

