0

I think I don't understand git and how to manage my package.json.

I have an older .Net Core 2.0 project that I am upgrading slowly to .Net 6. I have a git branch for this called newPlanGameUpgrade. In that branch, I had to remove a package in my package.json called aspnet-webpack because it's not compatiable with .Net 6.

So I did that, and got everything working in that branch.

But now, I just switched back to master to check something like this:

git checkout master
git pull origin master

I cleaned and rebuilt the solution, but I still get this error:

NodeInvocationException: Webpack dev middleware failed because of an error while loading 'aspnet-webpack'. Error was: Error: Cannot find module 'aspnet-webpack'

So I am guessing that git doesn't save different versions of package.json?

Is there anything I can do?

Thanks!

SkyeBoniwell
  • 6,345
  • 12
  • 81
  • 185
  • 1
    You need to run `npm install` again every time your `package.json` changes – mousetail Jul 26 '22 at 14:12
  • 1
    git manages whatever files you tell it to manage (by running `git add`) and doesn't bother you about changes to whatever files you tell it to ignore (in a file called `.gitignore`) – IMSoP Jul 26 '22 at 14:12
  • 1
    @IMSoP oh ok thanks, I found my `.gitignore` file and see that `package-lock.json` is listed. Should I delete that? thanks! – SkyeBoniwell Jul 26 '22 at 14:15
  • 1
    https://stackoverflow.com/a/44210813/7976758 Found in https://stackoverflow.com/search?q=%5Bgit%5D+package-lock.json+commit – phd Jul 26 '22 at 14:17
  • @mousetail I think that will cause issues though because the version of package.json I have now for .Net 6 is different than the old version of .Net Core 2. – SkyeBoniwell Jul 26 '22 at 14:18
  • Git knows nothing about json and does not "manage" json files in any special way. Git will store the file's content the way it stores any other file's content; if you need something more than that, use a program other than Git to do that. – torek Jul 27 '22 at 00:21

0 Answers0