Yaron Levi
Yaron Levi

Reputation: 13085

React Native - Save project without node_modules folder, and create it later?

I've created a react native project with react-native init. Everything is fine, but now I want to save the project to some source control without the large node_modules library (80mb).

So later (when the source is checked out on a different computer for example) when I try to recreate the folder I use npm install. But now when I run react-native start (i am using windows) i get the error:
"cannot find module '.nodules/es5'"

The react-native init command did something inside the node_modules that the npm install is not doing. What am I missing?

Upvotes: 2

Views: 3521

Answers (1)

Mihir
Mihir

Reputation: 3912

It's not clear from your description how you have created the project in the first place. I'd recommend using react-native init projectName to properly create a project. To run react-native you need to first install react native globally- npm install -g react-native-cli

If you're using git and github for source control- react-native init command automatically generates a .gitignore file. Following files are excluded from being added in the source control.

OSX-

.DS_Store

Xcode-

build/

*.pbxuser !default.pbxuser *.mode1v3 !default.mode1v3 *.mode2v3 !default.mode2v3 *.perspectivev3 !default.perspectivev3 xcuserdata *.xccheckout *.moved-aside DerivedData *.hmap *.ipa *.xcuserstate project.xcworkspace

Android/IJ

.idea .gradle local.properties

Node.js

node_modules/ npm-debug.log

So even if you run git add . (which tracks all the files recursively in the source control) the aforementioned files will not be tracked.

Next time, if you want to generate your project on a different machine, you can simply run

git clone your_git_repo

and then

npm install.

Upvotes: 2

Related Questions