"npm start" vs. "ng serve"

4,353 views
Skip to first unread message

Robert Werner

unread,
Apr 10, 2017, 2:14:12 PM4/10/17
to Angular and AngularJS discussion
I'm trying to run an Angular 2 app I've downloaded from GitHub.  This works:
npm install
npm start

But this fails:
npm install
ng serve

The only difference I can see is that "npm start" appears to execute the following statement before it calls "ng serve" :
project@0.0.0 start /Users/MyUserName/Projects/SampleProject

I've searched for this error but cannot find anything.  What is it that this statement does and why does it fix the startup?

Robert

P.S. For the record, the error message I'm getting with "ng serve" [alone] is: You have to be inside an angular-cli project in order to use the serve command.

Sander Elias

unread,
Apr 10, 2017, 10:16:51 PM4/10/17
to Angular and AngularJS discussion
Hi Robert,

This sounds like you downloaded a project that's not build using the CLI. I prefer to use the CLI, but there are still a lot of things available that are not using it.
You might want to move into the CLI though. 

Regards
Sander

Robert Werner

unread,
Apr 11, 2017, 4:56:26 PM4/11/17
to Angular and AngularJS discussion
Sander,

Sorry for the delayed response.  Your link to "Moving your project to Angular CLI" clued me in to why "ng serve" was not working for me.

Up until now I thought that Angular CLI was a simple command-line tool to execute commands.  What I didn't realize is that issuing the following specially created a project to be Angular CLI aware: ng new app-name

What I was doing was simply performing a git clone command, which created a new folder, copied down file from GitHub but apparently did not properly setup the ".angular-cli.json" file.

Now things make sense.  Thank you!

Robert
Reply all
Reply to author
Forward
0 new messages