ng serve command not working
Please provide us with the following information:
OS?
MacOS Sierra
Versions.
angular-cli: 1.0.0-beta.28.3 node: 7.4.0 os: darwin x64
Repro Steps
After running 'ng serve' in an app created by 'ng new...' I get this output from the console:
`As a forewarning, we are moving the CLI npm package to "@angular/cli" with the next release,
which will only support Node 6.9 and greater. This package will be officially deprecated
shortly after.
To disable this warning use "ng set --global warnings.packageDeprecation=false".
** NG Live Development Server is running on http://localhost:4200. **
Hash: b17a9b8b2eeffaf40894 e Time: 6294ms
chunk {0} polyfills.bundle.js, polyfills.bundle.map (polyfills) 222 kB {4} [initial] [rendered]
chunk {1} main.bundle.js, main.bundle.map (main) 3.94 kB {3} [initial] [rendered]
chunk {2} styles.bundle.js, styles.bundle.map (styles) 10 kB {4} [initial] [rendered]
chunk {3} vendor.bundle.js, vendor.bundle.map (vendor) 2.64 MB [initial] [rendered]
chunk {4} inline.bundle.js, inline.bundle.map (inline) 0 bytes [entry] [rendered]
webpack: Compiled successfully.`
But when I navigate to the localhost:4200 in my browser, I get this message:
This site can’t be reached
localhost refused to connect.
Which to me indicates that there is nothing running on that port, contrary to what the output in the console says. If I try running in different ports, I get the same result. No error messages, just no server.
Any help would be really appreciated.
Thanks! We'll be in touch soon.
I can confirm that it now works for me.
I did un unistall and re-install for the npm angular-cli module
@lukejoliat if you have a Windows machine, could you try reinstalling the CLI? Let me know if it's fixed.
Live reload doesn't work for changes in .ts files. It works on html.
@angular/cli: 1.0.0-beta.30
node: 6.9.5
os: win32 x64
@angular/common: 2.4.6
@angular/compiler: 2.4.6
@angular/core: 2.4.6
@angular/flex-layout: 2.0.0-beta.4
@angular/forms: 2.4.6
@angular/http: 2.4.6
@angular/material: 2.0.0-beta.1
@angular/platform-browser: 2.4.6
@angular/platform-browser-dynamic: 2.4.6
@angular/router: 3.4.6
@angular/cli: 1.0.0-beta.30
@angular/compiler-cli: 2.4.6
@ngtools/webpack: 1.2.7
@kilgarenone a new version of @ngtools/webpack has been released recently.
Can you remove node_modules and npm install and see if that fixes it?
Cool.. @beeman Thank you.. It works
delete "node_modules" npm install
ng serve not working plz help me.
for any of you guys who still have the problem, you need to re-install angular-cli through this command
npm install -g @angular/cli
or if you are using the old cli, you can just updated by this command
ng update
Thanks man..
@lordnino thanx for you comment, fix my problem with angular-cli!!!!
Closing as the original poster has identified it's a local setup problem (https://github.com/angular/angular-cli/issues/4368#issuecomment-277152176).
Most of the comments here are also completely unrelated to the original one.
At last find the solution for ng command is not working issue ,Find the solution below http://itechiesol.blogspot.com/2017/07/angular-cli-ng-command-is-not-working.html
69% building modules 697/701 modules 4 active ...es@angular\common\src\facade\ 69% building modules 697/702 modules 5 active ...gular\common\src\facade\collec 69% building modules 698/702 modules 4 active ...gular\common\src\facade\collec 69% building modules 699/702 modules 3 active ...gular\common\src\facade\collec 69% building modules 700/702 modules 2 active ...gular\common\src\facade\collec 69% building modules 701/702 modules 1 active ...gular\common\src\facade\collec 69% building modules 702/703 modules 1 active ...@angular\common\src\facade\erHash: a0a14da72a6852660afd Time: 11803ms chunk {0} polyfills.bundle.js, polyfills.bundle.map (polyfills) 234 kB {4} [initial] [rendered] chunk {1} main.bundle.js, main.bundle.map (main) 4.04 kB {3} [initial] [rendered] chunk {2} styles.bundle.js, styles.bundle.map (styles) 9.71 kB {4} [initial] [rendered] chunk {3} vendor.bundle.js, vendor.bundle.map (vendor) 2.63 MB [initial] [rendered] chunk {4} inline.bundle.js, inline.bundle.map (inline) 0 bytes [entry] [rendered] webpack: Compiled successfully.
Can anyone help me? when i start to write "ng-serve/server" the app doesn't launch
As of March 2018, this problem has resurfaced. This shell script reproduces the problem:
# fail.sh
npm install -g @angular/cli
ng new dir
cd dir
npm install
ng serve --open
My browsers (Safari 11.0.3 and Chrome 65.0.3325.162) both claim that "the server unexpectedly
dropped the connection".
System
macOS High Sierra 10.13.3
$ uname -a
17.4.0 Darwin Kernel Version 17.4.0: Sun Dec 17 09:19:54 PST 2017; root:xnu-4570.41.2~1/RELEASE_X86_64 x86_64
$ node --version
v9.4.0
$ ng version
Angular CLI: 1.7.3
Node: 9.4.0
OS: darwin x64
Angular:
...
Debugging steps
The port, (4200) is correctly bound to node:
$ lsof -i :4200
COMMAND PID USER FD TYPE DEVICE SIZE/OFF NODE NAME
node 45087 developer 19u IPv4 0x8ad892271debf961 0t0 TCP localhost:4200 (LISTEN)
Both curl and Postman manage to load the bundle from ng correctly:
$ curl -L localhost:4200/
<!doctype html>
<html lang="en">
<head>
<meta charset="utf-8">
</head>
<body>
<app-root></app-root>
...
</html>
Safari 11.0.3 and Chrome 65.0.3325.162 both claim that "the server unexpectedly
dropped the connection".

Why are my browsers unable to connect to the Angular dev server, when curl and Postman can?
Update
Running ng serve --host 0.0.0.0 and visiting 0.0.0.0:4200 solves this.
I still do not understand why Chrome and Safari dislike localhost:4200.
thanks @lordnino problem solved 👍
@lordnino Thanks mate! simple
npm install -g @angular/cli
did the job...
As of March 2018, this problem has resurfaced. This shell script reproduces the problem:
# fail.sh npm install -g @angular/cli ng new dir cd dir npm install ng serve --openMy browsers (Safari
11.0.3and Chrome65.0.3325.162) both claim that "the server unexpectedly dropped the connection".System
macOS High Sierra 10.13.3
$ uname -a 17.4.0 Darwin Kernel Version 17.4.0: Sun Dec 17 09:19:54 PST 2017; root:xnu-4570.41.2~1/RELEASE_X86_64 x86_64$ node --version v9.4.0$ ng version Angular CLI: 1.7.3 Node: 9.4.0 OS: darwin x64 Angular: ...Debugging steps
The port, (4200) is correctly bound to node:
$ lsof -i :4200 COMMAND PID USER FD TYPE DEVICE SIZE/OFF NODE NAME node 45087 developer 19u IPv4 0x8ad892271debf961 0t0 TCP localhost:4200 (LISTEN)Both
curland Postman manage to load the bundle fromngcorrectly:$ curl -L localhost:4200/ <!doctype html> <html lang="en"> <head> <meta charset="utf-8"> </head> <body> <app-root></app-root> ... </html>Safari
11.0.3and Chrome65.0.3325.162both claim that "the server unexpectedly dropped the connection".Why are my browsers unable to connect to the Angular dev server, when
curland Postman can?Update
Running
ng serve --host 0.0.0.0and visiting0.0.0.0:4200solves this. I still do not understand why Chrome and Safari dislikelocalhost:4200.
Visiting http://127.0.0.1:4200/ worked for me.
This issue has been automatically locked due to inactivity. Please file a new issue if you are encountering a similar or related problem.
Read more about our automatic conversation locking policy.
This action has been performed automatically by a bot.