package.json 和远程 git 存储库

package.json and remote git repository

在我的 package.json 中,我定义了一个 GitHub repo 作为依赖项。

  "dependencies": {
    "react": "^16.3.0-alpha.1",
    "react-native": "0.54.0-rc.3",
    "react-native-maps": "https://github.com/Stophface/react-native-maps-0.20.1.git"
  },

我将此存储库本地克隆到我的计算机上,对代码进行更改并将其推送到存储库。然后我希望这些更改反映在我的项目中。因此,我删除了 node_modules 文件夹,然后用 yarn install 重新安装了 node_modules。 但是,我在代码中所做的更改并没有在本地播放...

我还可以

yarn add https://github.com/Stophface/react-native-maps-0.20.1.gityarn add https://github.com/Stophface/react-native-maps-0.20.1.git#refator-1 并且我创建的文件不存在。

虽然它适用于 npm install https://github.com/Stophface/react-native-maps-0.20.1.git

这是为什么?我在 repo 中看到了我在本地在线创建的文件。当我输入 yarn install 时,它们也应该安装在本地,对吗?

这是因为 npm 缓存.. 向您的提交添加标签(例如:v0.0.1):

git tag v0.0.1
git push origin           // push changes
git push origin --tags    // push tags

并在您的依赖项中写入:

"dependencies": {
  "react": "^16.3.0-alpha.1",
  "react-native": "0.54.0-rc.3",
  "react-native-maps": "github.com/Stophface/react-native-maps-0.20.1#YOURTAG"
}