0

I'm currently working on a project that imports some functionality from a library that I created.

The package.json file of my project looks like this:

...
"dependencies"{
  "@sean/my-library":"1.4.0-SNAPSHOT",
...

The library mainly takes care of validation. One day, I noticed that there was a defect in my-library, so I created a new branch and switched to the new branch from the master by a command

git checkout -b fix-validation-issue

I made some modifications on the fix-validation-issue branch. I ran the following commands to reflect the changes to my-project, as the current version of my-project had cache of the master branch of my-library.

rm -rf node_module/ .angular/ package-lock.json (under my-project)
npm run pack (under my-library, and then copy the package and npm run install the package)
npm install (under my-project)
npm run build (under my-project)
npm start (under my-project)

Then the changes were reflected, so I switched back to master and merged the branch.

But a few days ago, I found another problem in my-library, so I created another branch to work on that.

git checkout -b handle-redundant-message

First I tried to find out the cause of the problem by setting a bunch of console.log statements to check the values of variables. I ran the series of commands that I mentioned above again to refresh the cache and reflect the changes. However, this time, none of the changes was reflected in my-project at all.

When changes on a new branch are not reflected on the project, what could be the cause?

Sean2014
  • 531
  • 8
  • 30
  • In Git, when you create a new branch from the current commit you are on (like you did), nothing in your working folder changes. Therefore, my suspicion is that this isn't a Git question, and whatever problem you're having would have still happened even if you didn't switch to a new branch. – TTT May 05 '22 at 13:18
  • It turns out that it was package-lock.json file that was causing the trouble. Once I deleted it AFTER running npm run pack instead of before, it began to work fine. – Sean2014 May 06 '22 at 16:58
  • Great. In case this helps you, if you want to use package-lock.json, you could use `npm ci` instead of `npm install`. Most people recommend using and checking in package-lock.json. [More info here.](https://stackoverflow.com/q/44206782/184546) – TTT May 06 '22 at 17:07

0 Answers0