Do you want to request a feature or report a bug?
Bug
What is the current behavior?
Running yarn add against a GitHub dependency correctly installs the specified branch/commit of that dependency. But when using yarn install to get the dependency again (e.g. on new machine or after cleaning node_modules), the wrong version is installed.
If the current behavior is a bug, please provide the steps to reproduce.
$ echo {} > package.json
$ yarn add LinusU/react-native-popup-dialog#rn-modal
✨ Done in 1.31s.
$ shasum -a 256 node_modules/react-native-popup-dialog/dist/PopupDialog.js
38143348b4c9e5ac42d67d6e5ce89c764968d073e9565fd453dccce9795c1920
$ rm -rf node_modules
$ yarn
✨ Done in 0.87s.
$ shasum -a 256 node_modules/react-native-popup-dialog/dist/PopupDialog.js
e04749ea0bbeb8d07b11f7f8279fdfe00a568b9625a538e04590b5ced4844323
As we can see, the first call to yarn add correctly installs the branch rn-modal from GitHub. However, when cleaning out node_modules and installing again, it takes the version from npm instead.
This is the relevant parts from package.json and yarn.lock:
"dependencies": {
"react-native-popup-dialog": "LinusU/react-native-popup-dialog#rn-modal"
}
react-native-popup-dialog@LinusU/react-native-popup-dialog#rn-modal:
version "0.18.3"
resolved "https://codeload.github.com/LinusU/react-native-popup-dialog/tar.gz/be1b91574ac1314ae9ab4f250598d713fff0e89a"
dependencies:
babel-plugin-flow-react-proptypes "^9.1.1"
prop-types "^15.6.0"
What is the expected behavior?
I expected the exact same package to be installed both times.
Please mention your node.js, yarn and operating system version.
$ node --version
v12.6.0
$ yarn --version
1.17.3
$ sw_vers
ProductName: Mac OS X
ProductVersion: 10.14.5
BuildVersion: 18F203
Yeah same problem for me here. Seems to be related to branches, because on default branches it works as expected. And Yarn always seems to be checking out the first commit on the branch. After yarn upgrade it's the newest version again, but this really isn't the solution ^^.
@LinusU Some more investigation: Clearing the Yarn cache seems to fix the issue because Yarn takes some old version of the package:
yarn cache clean [module-name]
That's at least a temporary solution until it is fixed.
Seems similar to https://github.com/yarnpkg/yarn/issues/4734 .
Most helpful comment
@LinusU Some more investigation: Clearing the Yarn cache seems to fix the issue because Yarn takes some old version of the package:
That's at least a temporary solution until it is fixed.