From 923bf38f20e955d4ac22a57125cdc5a38b4874bd Mon Sep 17 00:00:00 2001 From: Christopher Date: Tue, 28 May 2019 23:15:31 +0800 Subject: [PATCH] =?UTF-8?q?=E5=85=BC=E5=AE=B9=E6=96=B0=E7=89=88=E6=9C=AC?= =?UTF-8?q?=E4=BE=9D=E8=B5=96=E4=B8=8B=EF=BC=8C=E8=BF=90=E8=A1=8C=E6=B5=8B?= =?UTF-8?q?=E8=AF=95=E7=94=A8=E4=BE=8B=E6=97=B6=E9=87=8D=E5=A4=8D=E7=9B=91?= =?UTF-8?q?=E5=90=AC=E5=90=8C=E4=B8=80=E7=AB=AF=E5=8F=A3=E7=9A=84=E9=97=AE?= =?UTF-8?q?=E9=A2=98?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- lesson8/app.js | 10 +++++++--- 1 file changed, 7 insertions(+), 3 deletions(-) diff --git a/lesson8/app.js b/lesson8/app.js index c0f266b..b479f1f 100644 --- a/lesson8/app.js +++ b/lesson8/app.js @@ -35,6 +35,10 @@ app.get('/fib', function (req, res) { module.exports = app; -app.listen(3000, function () { - console.log('app is listening at port 3000'); -}); +// 测试用例运行时,不监听端口 +// 兼容新版本依赖下,运行测试用例时重复监听同一端口,导致测试用例无法退出(端口没有被使用)或监听端口报错的问题(端口已被使用) +if(!module.parent){ + app.listen(3000, function () { + console.log('app is listening at port 3000'); + }); +}