zoukankan      html  css  js  c++  java
  • NodeJs学习历程

    NPM 使用介绍

    npm就相当于 java中的maven工程。使用它可以方便灵活的管理第三方依赖

    npm install npm -g

    一般用nodejs,可以用pm2管理

    安装方式: npm install pm2

    pm2常用命令: https://www.npmjs.com/package/pm2

    1.pm2 ls 查看node启动情况,列出由pm2管理的所有进程信息,还会显示一个进程会被启动多少次,因为没处理的异常
    2.pm2 monit 监视每个node进程 的cpu 和内存的使用情况
    3.pm2 restart 0 重启node并将node重启次数置为0
    4.pm2 start 0
    5.pm2 shop 0

    Node.js REPL(交互式解释器):

    这种交互模式跟python交互模式基本类似

    使用nodejs创建第一个应用步骤:

    var http = require('http');  

    http.createServer(function (request, response) {

        // 发送 HTTP 头部,HTTP 状态值: 200 : OK,内容类型: text/plain

        response.writeHead(200, {'Content-Type': 'text/plain'});

        // 发送响应数据 "Hello World"

        response.end('Hello World ');

    }).listen(8888);

    使用 ,http://127.0.0.1:8888  即可访问。

    Node.js 回调函数:

  • 相关阅读:
    在 Spring 中使用 Quartz
    Quartz 快速进阶
    任务调度概述
    Spring Boot 2.x 整合 Mybatis 3.x
    pwd函数实现
    07-图4 哈利·波特的考试 (25 分)
    06-图3 六度空间 (30 分)
    linux中的目录
    Linux中的文件
    06-图2 Saving James Bond
  • 原文地址:https://www.cnblogs.com/pzyin/p/6737672.html
Copyright © 2011-2022 走看看