react-native-template-typescript: can not run `npx react-native init MyApp --template react-native-template-typescript`

Bug

Environment info

React native info output:

 // paste it here

Library version: x.x.x

Steps To Reproduce

…

Describe what you expected to happen:

Reproducible sample code

yarn add v1.17.3
[1/4] πŸ”  Resolving packages...
warning jest > jest-cli > jest-config > jest-environment-jsdom > jsdom > left-pad@1.3.0: use String.prototype.padStart()
error An unexpected error occurred: "https://registry.npmjs.org/react-native-template-react-native-template-typescript: Not found".
info If you think this is a bug, please open a bug report with the information provided in "/Users/kenny/react0611/yarn-error.log".
info Visit https://yarnpkg.com/en/docs/cli/add for documentation about this command.
yarn remove v1.17.3
[1/2] πŸ—‘  Removing module react-native-template-react-native-template-typescript...
error This module isn't specified in a package.json file.
info Visit https://yarnpkg.com/en/docs/cli/remove for documentation about this command.
warn Failed to clean up template temp files in node_modules/react-native-template-react-native-template-typescript. This is not a critical error, you can work on your app.
(node:2599) UnhandledPromiseRejectionWarning: Error: Command failed: yarn add react-native-template-react-native-template-typescript
    at makeError (/Users/kenny/react0611/node_modules/execa/index.js:174:9)
    at Promise.all.then.arr (/Users/kenny/react0611/node_modules/execa/index.js:278:16)
    at process._tickCallback (internal/process/next_tick.js:68:7)
(node:2599) UnhandledPromiseRejectionWarning: Unhandled promise rejection. This error originated either by throwing inside of an async function without a catch block, or by rejecting a promise which was not handled with .catch(). (rejection id: 3)
(node:2599) [DEP0018] DeprecationWarning: Unhandled promise rejections are deprecated. In the future, promise rejections that are not handled will terminate the Node.js process with a non-zero exit code.
k

About this issue

  • Original URL
  • State: closed
  • Created 5 years ago
  • Reactions: 5
  • Comments: 36 (8 by maintainers)

Commits related to this issue

Most upvoted comments

Just remember to npm uninstall -g react-native-cli and yarn global add @react-native-community/cli so you have new features during starting a new project

Can you try adding the --ignore-existing flag?

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

@Kennytian maybe you also need run yarn global remove react-native-cli

After uninstalling the old cli

npm uninstall -g react-native-cli

and install the new one

npm i -g @react-native-community/cli

and upgrade node

npm install -g npm@latest

the template created smoothly

@emin93 Thanks for your reply, npx --ignore-existing react-native init MyApp --template react-native-template-typescript it’s work.

Thanks all the same @KingAmo @PeterKow @radko93 @MateusAndrade !

               ######                ######               
             ###     ####        ####     ###             
            ##          ###    ###          ##            
            ##             ####             ##            
            ##             ####             ##            
            ##           ##    ##           ##            
            ##         ###      ###         ##            
             ##  ########################  ##             
          ######    ###            ###    ######          
      ###     ##    ##              ##    ##     ###      
   ###         ## ###      ####      ### ##         ###   
  ##           ####      ########      ####           ##  
 ##             ###     ##########     ###             ## 
  ##           ####      ########      ####           ##  
   ###         ## ###      ####      ### ##         ###   
      ###     ##    ##              ##    ##     ###      
          ######    ###            ###    ######          
             ##  ########################  ##             
            ##         ###      ###         ##            
            ##           ##    ##           ##            
            ##             ####             ##            
            ##             ####             ##            
            ##          ###    ###          ##            
             ###     ####        ####     ###             
               ######                ######               
                                                          

                  Welcome to React Native!                
                 Learn Once Write Anywhere                

βœ” Downloading template
βœ– Copying template
error RangeError: Maximum call stack size exceeded

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

Show similar error

Best solution I found

Remove

npm uninstall -g react-native-cli

Create the folder where the project will be

mkdir [folder name] && cd [folder name]

Install the dependencies and everything will work

yarn init
yarn add react-native
yarn react-native init [Project Name] ...

This works for me πŸŽ‰

npx react-native init ProjectName --npm

Best solution I found

Remove

npm uninstall -g react-native-cli

Create the folder where the project will be

mkdir [folder name] && cd [folder name]

Install the dependencies and everything will work

yarn init
yarn add react-native
yarn react-native init [Project Name] ...

Thank you so much, @carlosstenzel. Your solution was the only one that worked for me.

Can you try adding the --ignore-existing flag?

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

thanks for your reply! It worked for me!

After I upgraded to yarn version 1.21.1, this problem has been resolved.

Just tested it here without any global package related to react-native cli on the global packages and it returns a similar error:

Removing module react-native-template-react-native-template-typescript...
error This module isn't specified in a package.json file.
info Visit https://yarnpkg.com/en/docs/cli/remove for documentation about this command.
warn Failed to clean up template temp files in node_modules/react-native-template-react-native-template-typescript. This is not a critical error, you can work on your app.

Tested with: npx react-native init MyApp --template react-native-template-typescript and npx react-native init MyApp --template react-native-template-typescript@6.2.0

in my case I had to reset yarn yarn set version 1.22.1 my yarn version was 3.2.0

In my case after uninstalling the CLI, I also had to update the node version to 16.14.0 to work properly

Try update yarn. Run curl --compressed -o- -L https://yarnpkg.com/install.sh | bash It helped me

Running the following command -

npx react-native init app --template react-native-template-typescript@6.2.0

Which is being introduced in the official React Native website here (substituted MyTSProject with app)

Results in the same output as above.

error An unexpected error occurred: "https://registry.yarnpkg.com/react-native-template-react-native-template-typescript: Not found".
info If you think this is a bug, please open a bug report with the information provided in "/home/user/dev/App/mobile/app/yarn-error.log".
info Visit https://yarnpkg.com/en/docs/cli/add for documentation about this command.
yarn remove v1.13.0
[1/2] Removing module react-native-template-react-native-template-typescript@6.2.0...
error This module isn't specified in a package.json file.
info Visit https://yarnpkg.com/en/docs/cli/remove for documentation about this command.
warn Failed to clean up template temp files in node_modules/react-native-template-react-native-template-typescript@6.2.0. This is not a critical error, you can work on your app.
(node:31167) UnhandledPromiseRejectionWarning: Error: Command failed: yarn add react-native-template-react-native-template-typescript@6.2.0
    at makeError (/home/user/dev/App/mobile/app/node_modules/execa/index.js:174:9)
    at Promise.all.then.arr (/home/user/dev/App/mobile/app/node_modules/execa/index.js:278:16)
    at process._tickCallback (internal/process/next_tick.js:68:7)
(node:31167) UnhandledPromiseRejectionWarning: Unhandled promise rejection. This error originated either by throwing inside of an async function without a catch block, or by rejecting a promise which was not handled with .catch(). (rejection id: 3)
(node:31167) [DEP0018] DeprecationWarning: Unhandled promise rejections are deprecated. In the future, promise rejections that are not handled will terminate the Node.js process with a non-zero exit code.

@PeterKow 's answer solved this issue

@GreatAuk you can always install the old CLI again if anything bad happens. But I think it should be fine.

npm install -g react-native-cli still download old CLI, not https://github.com/react-native-community/cli ?

Confirm, I’ve run in the same issue in the end βœ– Copying template error RangeError: Maximum call stack size exceeded

Then just end up installing RN and adding TS manually as in here -> https://facebook.github.io/react-native/docs/typescript

Sorry for late reply