Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

react-native init in current folder

Tags:

I have a folder setup with some files I already want to have in the folder. I want to be able to run

react-native init PROJECTNAME

and instead of creating a folder PROJECTNAME it would init a react-native project in the folder I am currently in.

Is this possible?


Currently, I have my setup already created from previous projects that I enjoy using (packages.json, config files, etc). I delete the node_modules, and then react-native init PROJECTNAME. Then I take the PROJECTNAME/ios PROJECTNAME/android folders generated within that folder, move them into the main project folder and it works pretty smoothly. Just not optimal.

like image 918
Austin Witherow Avatar asked Feb 10 '16 15:02

Austin Witherow


People also ask

How do I create a React Native app in the current folder?

Use a dot for the path to create a React app in the current directory, e.g. npx create-react-app . or npx create-react-app . --template typescript for TypeScript projects. Make sure your folder name doesn't contain special characters, spaces or capital letters.

How do you use Expo in React Native?

Running your React Native applicationInstall the Expo Go app on your iOS or Android phone and connect to the same wireless network as your computer. On Android, use the Expo Go app to scan the QR code from your terminal to open your project. On iOS, use the built-in QR code scanner of the default iOS Camera app.


3 Answers

You can do

$ cd .. && react-native init folder_name

It will overwrite your package.json but keep the non-default files.

like image 130
Viktor Sec Avatar answered Sep 19 '22 14:09

Viktor Sec


This issue is currently tracked there.

like image 28
Żabojad Avatar answered Sep 20 '22 14:09

Żabojad


You should have install react-native-cli instead of react-native globally as described here.

And then the command is:

npx react-native-cli init appname --directory ./appPathToDir

like image 2
Pavol Travnik Avatar answered Sep 22 '22 14:09

Pavol Travnik