Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

ReactJS - Module not found: Error: Can't resolve 'App'

I just create a React project using create-react-app and after setting up, I got this error:

Failed to compile.

Module not found: Error: Can't resolve 'App' in 'C:\Development_Projects\international-school-fe\src'
ERROR in ./src/index.tsx 4:0-22
Module not found: Error: Can't resolve 'App' in 'C:\Development_Projects\international-school-fe\src'

webpack compiled with 1 error

Here is my jsconfig.json:

{
  "compilerOptions": {
    "baseUrl": "src",
    "checkJs": true,
    "jsx": "react"
  },
  "include": ["src"]
}

index.tsx:

import App from "App";
import "common/styles/spacing/margin/index.css";
import "common/styles/spacing/padding/index.css";
import React from "react";
import ReactDOM from "react-dom";
import "./index.css";

ReactDOM.render(
  <React.StrictMode>
    <App />
  </React.StrictMode>,
  document.getElementById("root")
);

I wonder what I did wrong, I want to set path for importing at the src folder, that's why I'm using jsconfig.json

like image 697
Huan Huynh Avatar asked Feb 22 '26 07:02

Huan Huynh


2 Answers

If you are using TypScript in your project, make sure the tsconfig.json file exists. Otherwise, create this file manually or by running this command:

npx tsc --init
like image 71
Tayyab Chaudhary Avatar answered Feb 23 '26 20:02

Tayyab Chaudhary


Create tsconfig file using

npx tsc --init

After that add this to allow jsx in typescript.

{
  "compilerOptions": {
    "jsx": "react",
     .....
}
like image 28
Nama Avatar answered Feb 23 '26 21:02

Nama