question-mark
Stuck on an issue?

Lightrun Answers was designed to reduce the constant googling that comes with debugging 3rd party libraries. It collects links to all the places you might be looking at while hunting down a tough bug.

And, if you’re still stuck at the end, we’re happy to hop on a call to see how we can help out.

typescript didn't enabled for a fresh CRA app

See original GitHub issue

I have a CRA app. I want to start using typescript. according to this guide for adding typescript to an existing Create React App project I installed the typescript and required type definitions:

npm install --save typescript @types/node @types/react @types/react-dom @types/jest

and add a file named test.tsx contains:

export default function Test(){
    return (
        <div>this is test to see typescirpt</div>
    )
}

and import and use it in main.js ctrl+c previous development server. and did npm start. I’m getting bellow error.

    Failed to compile.  
    Module not found: Error: Can't resolve './test' in '/home/g/w/projects/movie_watch_list_frontend/src'   
    ERROR in ./src/App.js 15:0-26  
    Module not found: Error: Can't resolve './test' in '/home/g/w/projects/movie_watch_list_frontend/src'  
    webpack compiled with 1 error

also, there isn’t any auto-created tsconfig file in the project folder.

I pushed the change that I made in a new branch named typescript to my reposity

also, I repeat this process for a fresh CRA app, and the same error happened.

am I doing something wrong?

_Originally posted by @j0053f in https://github.com/facebook/create-react-app/discussions/12295_

Issue Analytics

  • State:open
  • Created a year ago
  • Reactions:2
  • Comments:7

github_iconTop GitHub Comments

1reaction
await-ovocommented, Apr 18, 2022

@await-ovo look at verifyNoTypeScript function in create-react-app/packages/react-scripts/scripts/utils/verifyTypeScriptSetup.js if there is typescript files, tsconfig.json must automatically create.

that’s right, it seems that this function is only used when init.

0reactions
MatthewThorntoncommented, Oct 21, 2022

same issue.

Read more comments on GitHub >

github_iconTop Results From Across the Web

Module not found: Error: Can't resolve the typescript file when ...
I used a fresh create-react-app project, followed the documentation, and saw this error. (why?) this is my installed dependencies: "dependencies ...
Read more >
Create React App and TypeScript: A Quick How-To | Built In
Let's take a look at creating a new React app that uses TypeScript from the jump, and convert an existing project from JavaScript...
Read more >
React | WebStorm Documentation - JetBrains
React is a JavaScript library for building complex interactive User Interfaces from encapsulated components. Learn more about the library ...
Read more >
TypeScript and React using create-react-app - Level Up Coding
Use .tsx files for JSX ... In addition to a new .ts file for TypeScript, there is also a new file extension .tsx...
Read more >
Strict Mode - React
You can enable strict mode for any part of your application. For example: ... new createRef API. You don't need to replace callback...
Read more >

github_iconTop Related Medium Post

No results found

github_iconTop Related StackOverflow Question

No results found

github_iconTroubleshoot Live Code

Lightrun enables developers to add logs, metrics and snapshots to live code - no restarts or redeploys required.
Start Free

github_iconTop Related Reddit Thread

No results found

github_iconTop Related Hackernoon Post

No results found

github_iconTop Related Tweet

No results found

github_iconTop Related Dev.to Post

No results found

github_iconTop Related Hashnode Post

No results found