程序员

node基础

2018-07-20  本文已影响5人  X了个code

http & url

const http = require('http');
const url = require('url');
http.createServer((req, res) => {
    res.writeHead(200, {'Content-Type': 'text/html; charset=utf-8' });
    console.log(req.url);
    console.log(url.parse(req.url,true));

    res.end('哈哈');
}).listen(8080);

包管理

npm init

安装包

eg :
npm i supervior --save // 加载模块
npm i supervior --save-dev // 加载模块、测试、文档框架

1、使用 npm install node_module –save 自动更新 dependencies 字段值;
2、使用 npm install node_module –save 自动更新 dependencies 字段值;

版本号相关知识

如:

'express':'^2.1.1' // 表示第一位不变,后面两位取最新的
'express':'~2.1.1' // ~表示前两位不变,最后一个取最新 
'express':'*2.1.1' // *表示全部取最新
上一篇 下一篇

猜你喜欢

热点阅读