Angular App won't run after Cloning from a Git Repository

Viewed 19485

I recently completed the Angular Tour of Heroes tutorial (with some slight modifications) and it all works fantastically well. I then wanted to try push it up to a GIT repo in VSTS, and then clone it to another machine and run it from there. Unfortunately now I've cloned it to the new machine I'm unable to get it running. Both ng serve --open and ng build fail.

Originally it was complaining about missing "@angular-devkit/build-angular" so I went ahead and installed that, unfortunately on the next build attempt there was another issue

"Cannot find module '@angular-devkit/build-optimizer'"

Is it going to be the case that I need to reinstall every dependency every time I clone a solution using Angular or Node, or is there a simple command I'm missing here?

Google suggested I try "npm install -g npm-install-missing" and "npm rebuild", unfortunately neither helped.

6 Answers

After cloning the project just follow the instructions.

cd 'your project name...'

And then install the packages and dependencies.

npm install

and then you can run the project by running this code.

ng serve

This should work fine.

You need to npm install before serving

The issue looks like it was caused as I cloned my project to a sub folder of my VS workspace instead of the root. Once I cleared out the entire folder, recloned at the root, and then run npm install, everything worked fine.

I was facing the same issue and It got resolved using the below written method

  1. Type this command in your cmd: npm install -g npm@latest
  2. Clone your repository
  3. Run npm install and npm update
  4. Run ng serve

on your terminal make sure you are on the cloned project directory. if not cd into it

cd <project-name>

then install the packages used by running this command on your terminal;

npm install

after successful install you can now serve by running;

ng s --o

Go to your Project folder -

cd c:/MYProjectFolder

install packages by running -

npm install

finally -

ng serve --o

Related