由于getaddrinfo ENOTFOUND错误,无法启动使用angular-cli生成的angular2项目

时间:2016-12-02 09:01:53

标签: angular angular-cli

我正在使用Mac,OSX El Capitan 10.11.2,并尝试使用angular-cli启动angular2应用程序。根据文件,我运行了以下

$sudo ng new dashboard
$cd dashboard
$sudo ng serve
Password:
getaddrinfo ENOTFOUND localhost
Error: getaddrinfo ENOTFOUND localhost
    at errnoException (dns.js:28:10)
    at GetAddrInfoReqWrap.onlookup [as oncomplete] (dns.js:76:26)

但是我越来越高,我不明白。

2 个答案:

答案 0 :(得分:6)

尝试使用此命令: ng serve --port 4200 --host 0.0.0.0

答案 1 :(得分:4)

确保您的hosts文件中有localhost条目。

127.0.0.1       localhost
相关问题