Search code examples
node.jsreactjstypescriptcreate-react-app

'npx create-react-app [name] --template typescript' error


This is the error I get: https://i.sstatic.net/1nXn0.jpg

Literally, a few minutes ago I was able to create projects with "npx create-react-app [NAME] --template typescript" ... now I get this error. I've tried updating node.js, removing the node_modules folder, and other things but nothing's working. I'm a new developer so I try not to ask too many questions but this is really frustrating.


Solution

  • So this might not be a true fix, but rather a workaround:

    In your created app folder, open package.json file.

    Change react-scripts and typescript versions, to:

    "react-scripts": "3.4.4",
    "typescript": "^3.2.1",
    

    Next, remove package.lock.json, yarn.lock, node_modules and tsconfig.json. Run $ npm install and then $ npm start should work normally.

    Note that here we are using an older version of react-scripts.