与React本地团队一起使用git

与React本地团队一起使用git,git,react-native,Git,React Native,我当前的.gitignore文件具有: # OSX # .DS_Store # Xcode # build/ *.pbxuser !default.pbxuser *.mode1v3 !default.mode1v3 *.mode2v3 !default.mode2v3 *.perspectivev3 !default.perspectivev3 xcuserdata *.xccheckout *.moved-aside DerivedData *.hmap *.ipa *.xcusersta

我当前的
.gitignore
文件具有:

# 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/IntelliJ
# build/ .idea .gradle local.properties
*.iml

# node.js
node_modules/ npm-debug.log yarn-error.log

# BUCK buck-out/ \.buckd/
*.keystore

# fastlane
#
# It is recommended to not store the screenshots in the git repo. Instead, use fastlane to re-generate the
# screenshots whenever they are needed.
# For more information about the recommended setup visit:
# https://docs.fastlane.tools/best-practices/source-control/

*/fastlane/report.xml
*/fastlane/Preview.html
*/fastlane/screenshots

# Bundle artifact
*.jsbundle

#React Files
android/
ios/
然后,我照常做了

git add .
git commit -am "First commit"
git push -u origin master
它装上了子弹

当团队成员执行git克隆时 然后安装了
npm

它没有装载任何东西

package.json

{
  "name": "gmxWorldWide",
  "version": "0.0.1",
  "private": true,
  "scripts": {
    "start": "node node_modules/react-native/local-cli/cli.js start",
    "test": "jest"
  },
  "dependencies": {
    "react": "16.4.1",
    "react-native": "0.56.0",
    "watchman": "^1.0.0"
  },
  "devDependencies": {
    "babel-jest": "23.4.0",
    "babel-preset-react-native": "5",
    "jest": "23.4.1",
    "react-test-renderer": "16.4.1"
  },
  "jest": {
    "preset": "react-native"
  }
}
它不安装任何东西

我来自
php
background,在那里
composer.json
将在整个团队中复制,而
composer安装
将完成这一任务

它有什么不同,可以做什么来启用
npm安装
执行此工作

编辑:


代码是使用
react native init
命令创建的,因为您已将
node\u modules
目录提交给git,所以在克隆应用程序时,您所需的模块已经加载。您必须从存储库中忽略
node\u modules
。但是我在
中看到,gitinore
中已经对其进行了注释

# node.js
# node_modules/ npm-debug.log yarn-error.log
更新如下(联合国评论)

创建react本机应用程序的最佳方法是使用
创建react本机应用程序
。在这里阅读更多

编辑: 您必须提交
package lock.json
文件,以确保所有团队都使用相同的库版本。但无论如何,这可能会增加一些麻烦,因为每个
npm安装
可能会将现有包更新为
package.json
文件中提到的所需版本

有关package-lock.json的更多详细信息,请参见:

第二次编辑:
如果要锁定版本,请使用package.json文件。只需使用确切的软件包版本,而不是使用版本范围(React附带了一个内置命令)

我们执行了:

react native eject

它用本机代码在项目中重新创建了Android和iOS文件夹

拉动后:

npm install
react-native eject

尝试过。不起作用。问题是使用git和npm安装复制团队位于同一页面上。模块由react native动态创建。我已经回答了我的问题。请参阅下文。
....
"dependencies": {
    "react": "16.4.1",
    "react-native": "0.56.0",
    "watchman": "1.0.0"
  },
....
npm install
react-native eject