How can I use create-react-app for React version 16.x.x with TypeScript?

Viewed 12532

I need to run up a sandbox React app with version 16 and typescript.

Does anyone know how to do that as npx create-react-app --template=typescript blah now uses React 17?

Update

As suggested in the comments I've attempted to install with this:

npm init react-app migration-calculator-npm-demo --scripts-version 3.4.4

and

npm init react-app migration-calculator-npm-demo --template typescript --scripts-version 3.4.4

3.4.4 looks like the last version of react-scripts since before the major update.

Unfortunately, I'm getting errors with both.

internal/modules/cjs/loader.js:1088
throw err; ^

Error: Cannot find module 'cra-template'

and

internal/modules/cjs/loader.js:1088
throw err; ^

Error: Cannot find module 'cra-template-typescript'

2 Answers

I think this will help you to create react app with typescript.

 npx create-react-app my-app --scripts-version 16.XX.XX --template  typescript

npx create-react-app blah uses the version you have installed. If you have react package version 16 installed, then it will use version 16. You can also run a specific react-script version: Example: sudo npm init react-app my-app --scripts-version 3.4.0, Source

Related