当前第2页 返回上一页
server.js
1 2 3 4 5 6 | var http = require( 'http' );
http.createServer( function (req, res) {
res.writeHead(200, { 'Content-Type' : 'text/plain' });
res.end( 'Hello World\n' );
}).listen(3000, "127.0.0.1" );
console.log( 'Server running at http://127.0.0.1:3000/' );
|
现在使用命令启动node应用程序。
1 2 3 | $ node server.js
debugger listening on port 5858
Server running at http:
|
还可以使用以下命令启用调试来启动应用程序。
1 2 3 4 5 | $ node
Debugger listening on ws://127.0.0.1:9229/8976a32b-cf99-457c-85fb-e7288cbadac6
For help see https://nodejs.org/en/docs/inspector
Server running at http://127.0.0.1:3000/
|
Web服务器已在端口3000上启动。现在在浏览器中访问http://127.0.0.1:3000/url。现在,只需要为应用程序配置前端服务器。
本篇文章到这里就已经全部结束了,更多其他精彩内容可以关注PHP中文网的node.js视频教程栏目!!!
以上就是如何使用PPA在Ubuntu上安装最新的Node.js和NPM的详细内容,更多文章请关注木庄网络博客!
返回前面的内容
相关阅读 >>
如何从javascript到typescript?
nodejs怎么升级版本?两种方法介绍
nodejs如何升级版本?两种升级方法分享
node.js如何使用文件系统模块?常用fs模块方法介绍
深入了解node.js中的koa框架
mac下更新node.js到最新版
使用node.js “debug”模块避免日志污染应用程序日志
如何使用llama logs显示和调试nodejs错误?
nodejs和vuejs之间的差异
了解http事务、node模块化规范
更多相关阅读请进入《node.js》频道 >>
人民邮电出版社
本书对 Vue.js 3 技术细节的分析非常可靠,对于需要深入理解 Vue.js 3 的用户会有很大的帮助。——尤雨溪,Vue.js作者
转载请注明出处:木庄网络博客 » 如何使用PPA在Ubuntu上安装最新的Node.js和NPM