Cli: npx react-native init Demo --template react-native-template-typescript FAIL

Created on 28 Oct 2019  路  4Comments  路  Source: react-native-community/cli

Environment

System:
OS: macOS Mojave 10.14.5
CPU: (4) x64 Intel(R) Core(TM) i5-5257U CPU @ 2.70GHz
Memory: 1.32 GB / 16.00 GB
Shell: 3.2.57 - /bin/bash
Binaries:
Node: 10.14.1 - ~/.nvm/versions/node/v10.14.1/bin/node
Yarn: 1.9.4 - /usr/local/bin/yarn
npm: 6.4.1 - ~/.nvm/versions/node/v10.14.1/bin/npm
Watchman: 4.4.0 - /usr/local/bin/watchman
SDKs:
iOS SDK:
Platforms: iOS 12.2, macOS 10.14, tvOS 12.2, watchOS 5.2
Android SDK:
API Levels: 24, 28
Build Tools: 23.0.1, 24.0.0, 24.0.1, 24.0.2, 24.0.3, 26.0.2, 27.0.3, 28.0.3
System Images: android-24 | Google APIs Intel x86 Atom_64
IDEs:
Android Studio: 3.4 AI-183.6156.11.34.5522156
Xcode: 10.2/10E125 - /usr/bin/xcodebuild
npmPackages:
react: 16.9.0 => 16.9.0
react-native: 0.61.2 => 0.61.2
npmGlobalPackages:
react-native-cli: 2.0.1
react-native-tinker-cli: 1.7.0

Description

I'm creating a new App, and want to use typescript template. According to the init doc, I tried the following :

# This does NOT work, cli will throw an Error
npx react-native init Demo --template react-native-template-typescript

Then I tries this

# No error, but typescript is not configured
npx react-native init Demo --template typescript

So, how can we init app with typescript enabled?

bug report

Most helpful comment

@youngjuning

Please run below commands

  • npm list -g --depth=0
  • yarn global list

and paste the result here, bc probably you have installed old version of RN cli.
In my case I needed to use below commands to uninstall wrong version of cli

npm uninstall -g react-native
npm uninstall react-native-cli -g
yarn remove global react-native-cli

and then run

npx react-native init MyApp --template react-native-template-typescript

All 4 comments

Looks like npx react-native resolves to a globally installed react-native-cli. Please remove it, it's not needed anymore.

same issues

@youngjuning

Please run below commands

  • npm list -g --depth=0
  • yarn global list

and paste the result here, bc probably you have installed old version of RN cli.
In my case I needed to use below commands to uninstall wrong version of cli

npm uninstall -g react-native
npm uninstall react-native-cli -g
yarn remove global react-native-cli

and then run

npx react-native init MyApp --template react-native-template-typescript

@troZee's solution worked for me, just correcting their typo to save people a few googles (the global command must immediately follow yarn):

npm uninstall -g react-native
npm uninstall -g react-native-cli
yarn global remove react-native-cli
Was this page helpful?
0 / 5 - 0 ratings