Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

React native unable to download template

Tags:

react-native

Command

npx react-native@latest init AwesomeProject

Output

✔ Downloading template
✖ Copying template
error Error: Couldn't find the "/var/folders/8x/y10dxy554tzb5d5d2tv_rffh0000gn/T/rncli-init-template-c131XZ/node_modules/react-native/template.config.js file inside "react-native" template. Please make sure the template is valid. Read more: https://github.com/react-native-community/cli/blob/master/docs/init.md#creating-custom-template.
Error: Error: Couldn't find the "/var/folders/8x/y10dxy554tzb5d5d2tv_rffh0000gn/T/rncli-init-template-c131XZ/node_modules/react-native/template.config.js file inside "react-native" template. Please make sure the template is valid. Read more: https://github.com/react-native-community/cli/blob/master/docs/init.md#creating-custom-template
    at createFromTemplate (/Users/rmunoz/.npm/_npx/dea611a43221eddd/node_modules/@react-native-community/cli/build/commands/init/init.js:131:11)
    at process.processTicksAndRejections (node:internal/process/task_queues:95:5)
    at async Object.initialize [as func] (/Users/rmunoz/.npm/_npx/dea611a43221eddd/node_modules/@react-native-community/cli/build/commands/init/init.js:184:3)
    at async Command.handleAction (/Users/rmunoz/.npm/_npx/dea611a43221eddd/node_modules/@react-native-community/cli/build/index.js:106:9)
info Run CLI with --verbose flag for more details.

I checked the /var/ directory and /T/rncli-init-template-c131XZ/node_modules/react-native/template.config.js does NOT exist. I tried looking online for the template to just make it myself but i could not find it, i don't really even know where to look.

I followed the github link but i obviously do not want to create a custom template.

I did follow the documentation to install xcode cli tools and the correct version of ruby 2.7.6

like image 313
Rodrigo Munoz Avatar asked Feb 01 '26 21:02

Rodrigo Munoz


2 Answers

There is a warning at the top of the instructions you're following:

Note: If you have both yarn and npm installed on your machine, React Native CLI will always try to use yarn, so even if you use npx utility, only react-native executable will be installed using npm and the rest of the work will be delegated to yarn. You can force usage of npm adding --pm npm flag to the command.

You need to re-run your command with --pm npm:

npx react-native@latest init AwesomeProject --pm npm

But for modern versions (late 2024) the init command was deprecated and as of December 30th 2024 is removed entirely. It reports:

  • Switch to npx @react-native-community/cli init for the identical behavior.

So the new command is:

npx @react-native-community/cli init AwesomeProject --pm npm
like image 117
anothermh Avatar answered Feb 04 '26 15:02

anothermh


Today, in 2024, the answer to this question is: npx react-native@latest init AwesomeProject --pm npm

like image 31
devid Avatar answered Feb 04 '26 14:02

devid



Donate For Us

If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!