react-native: Unable to init new RN project
Description:
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
React Native version:
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
Steps To Reproduce
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.
Expected Results
A new RN project folder should be created with a ready template.
Snack, code example, screenshot, or link to a repository:
$ npx react-native init projectName
About this issue
- Original URL
- State: closed
- Created 4 years ago
- Reactions: 2
- Comments: 22
Hello friend, Make sure there is no
package.json
andnode_modules
at the dir where you are running thenpx
code. Try again and tell me if it worked.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
Is there a solution I have the same issue?
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 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
😊😊😊Running CMD/Powershell as admin on Windows fixed this issue for me.