I'm trying to init a new project using npx react-native init projectName --template react-native-template-typescript. It results in the following error:
$ npx react-native init projectName --template react-native-template-typescript
###### ######
### #### #### ###
## ### ### ##
## #### ##
## #### ##
## ## ## ##
## ### ### ##
## ######################## ##
###### ### ### ######
### ## ## ## ## ###
### ## ### #### ### ## ###
## #### ######## #### ##
## ### ########## ### ##
## #### ######## #### ##
### ## ### #### ### ## ###
### ## ## ## ## ###
###### ### ### ######
## ######################## ##
## ### ### ##
## ## ## ##
## #### ##
## #### ##
## ### ### ##
### #### #### ###
###### ######
Welcome to React Native!
Learn once, write anywhere
√ Downloading template
× Copying template
error Error: Couldn't find the "C:\Users\Ori\AppData\Local\Temp\rncli-init-template-aU61ll\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
And an empty folder is created.
Running just npx react-native init projectName produces the same result.
All of the related issues I could find (https://github.com/facebook/react-native/issues/27442, https://github.com/react-native-community/cli/issues/733, https://github.com/react-native-community/cli/issues/830, https://github.com/facebook/react-native/issues/26443) mentioned that having RN packages installed globally might be a problem. So before running I confirmed that there are no RN global packages installed:
$ npm uninstall react-native -g
$ npm uninstall react-native-cli -g
As mentioned I didn't have RN installed. But sometimes it gets installed globally on running npx react-native init projectName.
$ react-native info
error Unrecognized command "info".
info Run "react-native --help" to see a list of all available commands.
$ react-native --version
3.2.0
Here's some other relevant info:
OS: Windows 10 Pro
CPU: Intel(R) Core(TM) i5-7200U CPU @ 2.50GHz
Node: v12.16.0 - C:\Program Files\nodejs\node.exe
Npm: 6.13.4 - C:\Program Files\nodejs\npm.cmd
Python 2.7 - C:\\Users\\Ori\\.windows-build-tools\\python27\\python.exe
I guess this is working for other people but for just running npx react-native init projectName produces the error.
I also tried to reinstall Node and NPM but nothing changed.
I'm guessing it's something with my environment so please tell if you need any more info to debug this.
A new RN project folder should be created with a ready template.
$ npx react-native init projectName
Is there a solution I have the same issue?
Me too
Me too...
Sent from my Alcatel 3VEl 24 feb 2020 10:12, pablolucio97 notifications@github.com escribió:Me too...
—You are receiving this because you are subscribed to this thread.Reply to this email directly, view it on GitHub, or unsubscribe.
Hello friend,
Make sure there is no package.json and node_modules at the dir where you are running the npx code. Try again and tell me if it worked.
Hey all, sorry I couldn't reply earlier.
@wallace-sf's solution is what worked for me.
Hi
I have that same problem, help!
I have same this problem. npx react-native init doesn't work any more.
While this issue is investigating then we can use react-native-cli. It is working well.
npm install -g react-native-cli
react-native init helloworld
😊😊😊
Neither bachphuc or other soultion worked. This problem happened after I started using andriod studio but before that I used the expo app and I was able to work fine
I tried to init react native in the C:\user\MYUSERNAME\ and that caused the error. I ran react-native init projectname after i "cd" into my desktop then worked fine!
I still have the same error too. Then I try something:
npm uninstall -g react-native
npm uninstall react-native-cli -g
then install yarn:
npm install -g yarn
And well, I can create react native app with typescript template:
npx react-native init helloReact --template react-native-template-typescript
I still have the same error too. Then I try something:
npm uninstall -g react-native
npm uninstall react-native-cli -gthen install yarn:
npm install -g yarnAnd well, I can create react native app with typescript template:
npx react-native init helloReact --template react-native-template-typescript
I have followed your steps, but I still can not init a new RN app, is there any solution more? @MrHOY
Running CMD/Powershell as admin on Windows fixed this issue for me.
@HerbertHe
Have you tried as administrator?
@HerbertHe
Have you tried as administrator?
@MrHOY I have tried again just now not as administration, npm install react-native-cli -g and react-native init xxx, and it works today... But I don't know why until now, and npx react-native init xxx still can not work yet
I got the same error.
✔ Downloading template
✖ Copying template
error Error: Couldn't find the "/var/folders/6_/79s7b4bs6h96zm085jfwwf7c0000gp/T/rncli-init-template-4CQpoD/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
$ npx react-native --version
4.3.0
Currently, my work around is using expo to init the project then eject it:
$ npm install -g expo-cli
$ expo init awesomeApp
$ cd awesomeApp
$ expo eject
Select: Bare: I'd like a bare React Native project.
hi guys, hope y'all are doing good ...
i'm sorry but why this problem is closed while there is still a problem using react-native init without installing react-native-cli. i think this is a problem that must be fixed cause even 'https://reactnative.dev/docs' recommends not using react-native-cli, but
npx react-native init projectName does not work!!
i really love react but these problems makes people think that this is not a stable framework!!
thanks in advance
Hey @omidazm94, did you make sure you don't have react-native or react-native-cli installed globally, and that there's no node_modules folder or a package.json file in the directory you're trying to init RN in?
If so than you have a different issue I think. My problem was solved when I removed a node_modules folder I had laying around...
Hey @omidazm94, did you make sure you don't have
react-nativeorreact-native-cliinstalled globally, and that there's nonode_modulesfolder or apackage.jsonfile in the directory you're trying to init RN in?
If so than you have a different issue I think. My problem was solved when I removed anode_modulesfolder I had laying around...
thank you @OPerel for answering. i dont know what exactly was my problem and maybe im wrong but i think some versions of node and java are not compatible with each other or something that causes this problem (or maybe because i have to run vpn to access files that are needed during setup of project). im running java 12 and node 10 and everything is good . i meant that there are some problems that must be addressed in community. but thanks a lot and good luck to you friend!
find same issue.
follow this doc
i use npx react-native init MyProject --npm and it works.
This worked for me: npx react-native init MyProject --template react-native-template-typescript
i use
_npx react-native init MyProject --npm_and it works
Thank you!
It is worked for me
Most helpful comment
find same issue.
follow this doc
i use
npx react-native init MyProject --npmand it works.