跟我学NodeJS(二)

来源:互联网 发布:淘宝退款可以申请几次 编辑:程序博客网 时间:2024/06/05 06:01

1、新版的nodejs已经集成了npm,NPM是随同NodeJS一起安装的包管理工具,npm的作用就是对Node.js依赖的包进行管理,也可以理解为用来安装/卸载Node.js需要装的东西

e:\HTML5>npm -v3.10.10

2、使用 npm 命令安装模块,安装最常用的express模块

npm install express -g     # -g是全局安装的意思
D:\NodeJs\node_global`-- express@4.15.4  `-- accepts@1.3.4    `-- mime-types@2.1.17      `-- mime-db@1.30.0

3、使用npm list -g命令,查看全局的安装的模块

C:\Users\asus>npm list -gD:\NodeJs\node_global+-- express@4.15.4| +-- accepts@1.3.4| | +-- mime-types@2.1.17| | | `-- mime-db@1.30.0| | `-- negotiator@0.6.1| +-- array-flatten@1.1.1| +-- content-disposition@0.5.2| +-- content-type@1.0.2| +-- cookie@0.3.1| +-- cookie-signature@1.0.6| +-- debug@2.6.8| | `-- ms@2.0.0| +-- depd@1.1.1| +-- encodeurl@1.0.1| +-- escape-html@1.0.3| +-- etag@1.8.0| +-- finalhandler@1.0.4| | `-- unpipe@1.0.0| +-- fresh@0.5.0| +-- merge-descriptors@1.0.1| +-- methods@1.1.2| +-- on-finished@2.3.0| | `-- ee-first@1.1.1| +-- parseurl@1.3.1| +-- path-to-regexp@0.1.7| +-- proxy-addr@1.1.5| | +-- forwarded@0.1.0| | `-- ipaddr.js@1.4.0| +-- qs@6.5.0| +-- range-parser@1.2.0| +-- send@0.15.4| | +-- destroy@1.0.4| | +-- http-errors@1.6.2| | | `-- inherits@2.0.3| | `-- mime@1.3.4| +-- serve-static@1.12.4| +-- setprototypeof@1.0.3| +-- statuses@1.3.1| +-- type-is@1.6.15| | `-- media-typer@0.3.0| +-- utils-merge@1.0.0| `-- vary@1.1.1`-- grunt-cli@1.2.0  +-- findup-sync@0.3.0  | `-- glob@5.0.15  |   +-- inflight@1.0.6  |   | `-- wrappy@1.0.2  |   +-- inherits@2.0.3  |   +-- minimatch@3.0.4  |   | `-- brace-expansion@1.1.8  |   |   +-- balanced-match@1.0.0  |   |   `-- concat-map@0.0.1  |   +-- once@1.4.0  |   `-- path-is-absolute@1.0.1  +-- grunt-known-options@1.1.0  +-- nopt@3.0.6  | `-- abbrev@1.1.0  `-- resolve@1.1.7

4、doc命令输入node,类似系统终端(Read Eval Print Loop:交互式解释器)

C:\Users\asus>node> 1+45> 5/22.5> x=1010> console.log("hello,world")hello,worldundefined>