2017-08-31 62 views
0

controller.js代碼更新後的Node.js和NPM我的API不更新版本發送響應

router.get('/test1', (req, res) => { 
    // not hitting the api 
    console.log("api hitted"); 
}); 

節點-v [8.1.2]

NPM -v [ 5.0.3]

表達-v對TE [4.15.0]

輸出ST中get方法API與上述版本

在Ubuntu終端

curl -v xxxipxxx:3000/test1 
* Trying xxxxipxxx.. 
* Connected to xxxxipxxxx (xxxipxxxx) port 3000 (#0) 
> GET /test1 HTTP/1.1 
> Host: localhost:3000 
> User-Agent: curl/7.47.0 
> Accept: */* 

問題就在這裏 升級的節點版本

節點-v [8.4.0 ]

npm -v [5。 3.0]

快遞[4.15.0]

curl -v XXipXXXX:3000/test1 

    * Trying xxxipxxx... 
    * connect to xxipxxxx port 3000 failed: Connection timed out 
    * Failed to connect to xxxxipxxx port 3000: Connection timed out 
    * Closing connection 0 
    curl: (7) Failed to connect to xxxipxxx port 3000: Connection timed out 

預計

我想與版本8.4.0運行我因的NodeJS我已經我的一些節點是運行上述最新版本

在此先感謝

回答

0

否確定爲什麼第一個似乎工作,但我認爲問題是,你永遠不會返回一個響應,所以你的連接超時。

我建議你改變你的代碼返回響應:

router.get('/test1', (req, res) => { 
    // not hitting the api 
    console.log("api hitted"); 
    res.send() //add this line 
}); 
+0

我的代碼甚至不hitted這是問題,我認爲這個問題與版本不知道該API – muthukumar