Node.js总结

2018-10-12  本文已影响0人  慕名66

1.NodeJs官网地址

2.检查版本:node -v(node --version)

编写node程序

        ①var http = require('http'); //引行请求(require)Node.js 自带的 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\n'); 

            }).listen(8888);  

3.window下npm升级:npm install npm -g

 4.npm 安装 Node.js 模块语法格式: npm install 模块名称

    安装模块时报错:npm err! Error: connect ECONNREFUSED 127.0.0.1:8087

    解决办法,设置代理为null:  npm config set proxy null

    npm 的包安装分为本地安装(local)、全局安装(global)两种,从敲的命令行来看,差别只是有没有-g而已:

        npm install express # 本地安装

        npm install express -g # 全局安装 

5.卸载模块: npm uninstall 模块名称

6.查看安装模块:npm ls

7.更新模块:  npm update 模块名称

上一篇 下一篇

猜你喜欢

热点阅读