
上QQ阅读APP看书,第一时间看更新
2.2 在WebStorm中运行Node.js程序
在2.1节,我们编写了一个简单的Node.js程序,本节将讲解如何运行编写完成的Node.js程序,步骤如下。
(1)在WebStorm的代码编写区单击鼠标右键,在弹出的快捷菜单中选择“Run '***.js'”命令,即可运行Node.js程序,如图2.8所示。

图2.8 在右键快捷菜单中选择“Run '***.js'”命令
(2)运行Node.js程序,在WebStorm的下方将显示服务器的启动效果,如图2.9所示。

图2.9 在WebStorm的下方显示服务器的启动效果
(3)单击服务器运行结果中提示的网址,或者直接在浏览器地址栏中输入网址http:// 127.0.0.1:3000/,按Enter键,即可查看结果,如图2.10所示。同时,WebStorm下方将显示代码中设置的日志,如图2.11所示。

图2.10 在浏览器中通过网址查看结果

图2.11 在WebStorm下方显示代码中设置的日志