5

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'

OrderAndChaos
  • 3,547
  • 2
  • 30
  • 57

2 Answers2

0

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
Sagar Kumar
  • 55
  • 1
  • 5
  • 2
    The `react-scripts` versions are different from the `react` and `react-dom` versions. Here you can find the list of the current versions of `react-scripts`: [react-scripts versions](https://www.npmjs.com/package/react-scripts) – webpreneur Mar 04 '22 at 08:01
  • @Sagar Kumar, Your answer does not work as there is no react-scripts version 16. – Daniel Sep 01 '23 at 13:14
-1

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

Amel
  • 653
  • 9
  • 15
  • Do you know what version of react-scripts I should use? `1.1.5` looks old to me. – OrderAndChaos Nov 03 '20 at 15:19
  • 3.4.0 should work. You can also try 3.3.1. The version you used (3.4.4) was released 2 weeks ago? – Amel Nov 04 '20 at 10:10
  • I tried these and more the other day, I got the errors above. 1.1.5 works but does not support typescript templates. – OrderAndChaos Nov 04 '20 at 13:59
  • Hmm.. did you try to: 1.) Deinstall create-react-app globally: `npm uninstall -g create-react-app` 2.) Try again to create the app: `npm init react-app my-app --scripts-version 3.4.0` – Amel Nov 05 '20 at 08:55
  • I just tried that, the same issue. Did you have any luck with the command? Maybe somethings up with my npm. – OrderAndChaos Nov 05 '20 at 12:01
  • @Amel, I tried your solution and I got React 18, I think the OP was asking how to do it where you get React 16. – Daniel Sep 01 '23 at 13:11