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
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
Create tsconfig file using
npx tsc --init
After that add this to allow jsx in typescript.
{
"compilerOptions": {
"jsx": "react",
.....
}
If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!
Donate Us With