This is a demonstration repo for this npm issue.
Here are two scenarios where the unexpected behavior occurs:
Before trying each scenario, please make sure that you have run npm install
and there are no further local changes (reset after trying scenario 1).
You can see which branch is installed by checking the name of the file inside node_modules/@proj/source
, which is either main.branch
or dev.branch
.
- Change
package.json
to depend on thedev
branch (#dev
instead of#main
). Don't forget to save the file. - Run
npm install
- Check for the currently installed branch. It will still be
main.branch
.
For these steps, follow at least step 1 from above.
Weirdly, this happens before and after running npm install
in step 2 above.
- Delete the
node_modules
directory. - Run
npm install
. - As you will see,
main.branch
is present again, even though we just reinstalled all packages (caching issue?) For this behavior, the branch referenced inpackage-lock.json
doesn't matter.
- Switch to the
depends-on-dev
branch. - Run
npm install
- Check for the currently installed branch. It will still be
main.branch
.
Again, deleting node_modules
does not fix this.