0

whenever I sync a react native project in GitHub , GitHub ignores the npm-modules folder to sync.I was wondering why GitHub has this approach, is there any problem to include this folder in our GitHub project? I know there is ignore line in GitHub for this folder and also I know I can easily install npm module but sometimes you need to change some parts directly from library and those modifications cannot be install again by npm install.

Nima
  • 1,892
  • 4
  • 24
  • 32
  • 2
    Do you by any chance have a `.gitignore` that contains `node_modules/` in your repository? – Ingo Bürk Jul 21 '17 at 13:21
  • 3
    Possible duplicate of [Should "node\_modules" folder be included in the git repository](https://stackoverflow.com/questions/18128863/should-node-modules-folder-be-included-in-the-git-repository) – Ingo Bürk Jul 21 '17 at 13:22

1 Answers1

1

Github doesn't ignore anything, it is basically the same as git and it doesn't understand the structure of a react-native project.

The folder is ignored because it's in the .gitignore created by the react-native CLI.

To include nodes_modules in your git, just remove the line node_modules/ in your .gitignore and add/commit. You'll then be able to push your node_modules.

Uploading the node_modules folder is basically safe, but most people ignore it because you can generate it by npm install. That's why react-native put it in the default .gitignore.

See also Should "node_modules" folder be included in the git repository for whether you should include this folder or not.

Answer to the edit:

I know there is ignore line in GitHub for this folder and also I know I can easily install npm module but sometimes you need to change some parts directly from library and those modifications cannot be install again by npm install.

(It's not Github, it would be the same with another git server.)

If you decide not to include node_modules, and want to change a library, you can fork the library on Github and install your fork with npm: npm install <yourUsername>/<yourRepository> (if it's public).

xght
  • 48
  • 6