如何使用PPA在Ubuntu上安装最新的Node.js和NPM


当前第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://127.0.0.1:3000/

还可以使用以下命令启用调试来启动应用程序。

1

2

3

4

5

$ node --inspect server.js

 

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》频道 >>




打赏

取消

感谢您的支持,我会继续努力的!

扫码支持
扫码打赏,您说多少就多少

打开支付宝扫一扫,即可进行扫码打赏哦

分享从这里开始,精彩与您同在

评论

管理员已关闭评论功能...