I created a new Angular 10 app on a git feature branch. I set up the basic framework for it, then merged that feature branch into release. I created a new feature branch from release to start working on an enhancement and when I tried to run ng serve
, I got this error:
An unhandled exception occurred: Cannot find module '@angular-devkit/build-angular/package.json'
Looking at this SO answer (https://stackoverflow.com/a/51581991/787958), the solution was to run npm update
. This worked for me, but it seems like a major pain to need to do this on every new git branch. Is there something I can change in the gitignore file so that this is not necessary or is this just a standard pain that everyone has to deal with?
As of why you node_modules is grayed (I saw you comment), it's because it's not tracked by git which is a good thing, because you don't want to save all dependencies to your repository (there's like 50K files in there). This means that if you ever clone the project, you'll have to use
npm install
.I believe this would explain your problem. You might have clone the project and so you would have to use
npm install
to install dependencies. The reason whynpm update
did work it's because it compares the stable version of all dependencies you have in your package.json and upgrade to that stable version and then it installs all the dependencies.Hope this help you understand a little better.