在本地主机上的端口4200上的Web浏览器中看不到节点服务器

时间:2018-07-06 23:05:15

标签: node.js linux angular development-environment

我正在开发模式下在Pixelbook上运行基本的Angular服务器。我觉得我已经在一个普通的Ubuntu开发箱上做了很多次,但是这种Chrome风格的开发环境让我感到烦恼。

我可以启动服务器,该服务器基本上是Web服务器,并且可以使用wget从命令行调用它。但是,当我使用Chrome浏览器启动此功能时,出现连接被拒绝的错误。

我认为我更改了Chrome的默认设置,使其不受限制(例如不加载本地内容)。

我可以使用ng serve来运行服务器,并且我已经尝试过将主机指定为0.0.0.0、127.0.0.1和localhost-但没有运气。

我怀疑这与Chrome或Pixelbook Linux环境有关。

以下是我到目前为止已完成的基本故障排除。还有其他想法吗?

→ ng serve --host=0.0.0.0 --port=4200
** Angular Live Development Server is listening on 0.0.0.0:4200, open your browser on http://localhost:4200/ **

Date: 2018-06-30T17:00:32.284Z
Hash: ebb64e6046efff317389AQ
Time: 8398ms
chunk {main} main.js, main.js.map (main) 10.7 kB [initial] [rendered]
chunk {polyfills} polyfills.js, polyfills.js.map (polyfills) 227 kB [initial] [rendered]
chunk {runtime} runtime.js, runtime.js.map (runtime) 5.22 kB [entry] [rendered]
chunk {styles} styles.js, styles.js.map (styles) 15.6 kB [initial] [rendered]
chunk {vendor} vendor.js, vendor.js.map (vendor) 3.06 MB [initial] [rendered]
ℹ 「wdm」: Compiled successfully.

::从命令行命中服务器-OK ::

→ wget 0.0.0.0:4200
--2018-06-30 17:04:29--  http://0.0.0.0:4200/
Connecting to 0.0.0.0:4200... connected.
HTTP request sent, awaiting response... 200 OK
Length: 581 [text/html]
Saving to: ‘index.html’

index.html                     100%[=================================================>]     581  --.-KB/s    in 0s      

2018-06-30 17:04:29 (37.5 MB/s) - ‘index.html’ saved [581/581]

:::检查index.html以确认它是一个真实的HTML文件::

○ → head index.html 
<!doctype html>
<html lang="en">
<head>
  <meta charset="utf-8">
  <title>MyAngularApp</title>
  <base href="/">

  <meta name="viewport" content="width=device-width, initial-scale=1">
  <link rel="icon" type="image/x-icon" href="favicon.ico">
</head>

::打开Chrome,然后导航至0.0.0.0:4200,本地主机等::

This site can't be reached
ERR_CONNECTION_REFUSED

::检查ip配置::

→ ip a
1: lo: <LOOPBACK,UP,LOWER_UP> mtu 65536 qdisc noqueue state UNKNOWN group default qlen 1000
    link/loopback 00:00:00:00:00:00 brd 00:00:00:00:00:00
    inet 127.0.0.1/8 scope host lo
       valid_lft forever preferred_lft forever
    inet6 ::1/128 scope host 
       valid_lft forever preferred_lft forever
2: docker0: <NO-CARRIER,BROADCAST,MULTICAST,UP> mtu 1500 qdisc noqueue state DOWN group default 
    link/ether 02:42:ea:0e:81:de brd ff:ff:ff:ff:ff:ff
    inet 172.17.0.1/16 brd 172.17.255.255 scope global docker0
       valid_lft forever preferred_lft forever
4: eth0@if5: <BROADCAST,MULTICAST,UP,LOWER_UP> mtu 1500 qdisc noqueue state UP group default qlen 1000
    link/ether 00:16:3e:21:1b:be brd ff:ff:ff:ff:ff:ff link-netnsid 0
    inet 100.115.92.198/28 brd 100.115.92.207 scope global eth0
       valid_lft forever preferred_lft forever
    inet6 fe80::216:3eff:fe21:1bbe/64 scope link 
       valid_lft forever preferred_lft forever

::检查netstat并查看正在监听哪些端口::

→ netstat -noa|grep "LISTEN "
tcp        0      0 0.0.0.0:4200            0.0.0.0:*               LISTEN      off (0.00/0/0)
tcp        0      0 0.0.0.0:5355            0.0.0.0:*               LISTEN      off (0.00/0/0)
tcp        0      0 0.0.0.0:2222            0.0.0.0:*               LISTEN      off (0.00/0/0)
tcp6       0      0 :::5355                 :::*                    LISTEN      off (0.00/0/0)
tcp6       0      0 :::2222                 :::*                    LISTEN      off (0.00/0/0)
tcp6       0      0 :::8889                 :::*                    LISTEN      off (0.00/0/0)       

::验证IP表::

○ → sudo iptables -L
Chain INPUT (policy ACCEPT)
target     prot opt source               destination         
ACCEPT     all  --  anywhere             anywhere             ctstate RELATED,ESTABLISHED
ACCEPT     tcp  --  anywhere             anywhere             tcp dpt:http
ACCEPT     tcp  --  anywhere             anywhere             tcp dpt:4200

Chain FORWARD (policy ACCEPT)
target     prot opt source               destination         
DOCKER-USER  all  --  anywhere             anywhere            
DOCKER-ISOLATION-STAGE-1  all  --  anywhere             anywhere            
ACCEPT     all  --  anywhere             anywhere             ctstate RELATED,ESTABLISHED
DOCKER     all  --  anywhere             anywhere            
ACCEPT     all  --  anywhere             anywhere            
ACCEPT     all  --  anywhere             anywhere            

Chain OUTPUT (policy ACCEPT)
target     prot opt source               destination         

Chain DOCKER (1 references)
target     prot opt source               destination         

Chain DOCKER-ISOLATION-STAGE-1 (1 references)
target     prot opt source               destination         
DOCKER-ISOLATION-STAGE-2  all  --  anywhere             anywhere            
RETURN     all  --  anywhere             anywhere            

Chain DOCKER-ISOLATION-STAGE-2 (1 references)
target     prot opt source               destination         
DROP       all  --  anywhere             anywhere            
RETURN     all  --  anywhere             anywhere            

Chain DOCKER-USER (1 references)
target     prot opt source               destination         
RETURN     all  --  anywhere             anywhere            

1 个答案:

答案 0 :(得分:0)

使用以下命令启动服务器

var managers = [];

function findManagers(object) {
    for (var i in object) {
        if (object[i].IsManager === "TRUE") {
            managers.push(object[i]);

            if (object[i].children !== undefined) {
                findManagers(object[i].children);
            }
        }
    }
}

findManagers(employees);

console.log(managers);

在以下位置查看它:http://penguin.linux.test:4200/

library(lubridate) dmy("02-Jan-17") 实际上是Pixelbook上的setTimeout(function () { process.exit(); }, 5000);