0

I'm trying to create an app with React Native and TypeScript, but it's not working. I use the following commands:

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

And the log error:

Yarn version: 
  1.22.15

Node version: 
  16.10.0

Platform: 
  win32 x64

Trace: 
  Error: https://registry.yarnpkg.com/react-native-template-react-native-template-typescript: Not found
      at Request.params.callback [as _callback] (C:\Users\pc\AppData\Roaming\npm\node_modules\yarn\lib\cli.js:66140:18)
      at Request.self.callback (C:\Users\pc\AppData\Roaming\npm\node_modules\yarn\lib\cli.js:140885:22)
      at Request.emit (node:events:390:28)
      at Request.<anonymous> (C:\Users\pc\AppData\Roaming\npm\node_modules\yarn\lib\cli.js:141857:10)
      at Request.emit (node:events:390:28)
      at IncomingMessage.<anonymous> (C:\Users\pc\AppData\Roaming\npm\node_modules\yarn\lib\cli.js:141779:12)
      at Object.onceWrapper (node:events:509:28)
      at IncomingMessage.emit (node:events:402:35)
      at endReadableNT (node:internal/streams/readable:1343:12)
      at processTicksAndRejections (node:internal/process/task_queues:83:21)
2
  • 3
    According to the React Native docs (reactnative.dev/docs/typescript#getting-started-with-typescript): "Note: If the above command is failing, you may have an old version of react-native or react-native-cli installed globally on your system. To fix the issue try uninstalling the CLI: npm uninstall -g react-native-cli or yarn global remove react-native-cli and then run the npx command again." Commented Oct 8, 2021 at 18:17
  • Thanks a lot, now it's working after I've uninstalled reat-native-cli Commented Oct 8, 2021 at 18:57

2 Answers 2

1

you should first uninstall the previous react-native-cli to install the newest with the typescript features.

1- npm uninstall -g react-native-cli.

2- yarn global add @react-native-community/cli

3- react-native init MyApp --template react-native-template-typescript

Sign up to request clarification or add additional context in comments.

1 Comment

I was trying this way npx react-native init MyApp --template react-native-template-typescript. Just dropped npx and voilà
0

You can try

npx [email protected] init MyTestApp --version 0.65 --template [email protected]

Comments

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge you have read our privacy policy.

Start asking to get answers

Find the answer to your question by asking.

Ask question

Explore related questions

See similar questions with these tags.