-
express
-
三个以来插件
body-parser : 用来处理json,text请求参数
cookie-parser : 获取coolie对象
multer : 解决文件上传表单问题
NPM : Node Package Manger
包管理,分发工具,方便JavaScript开发中下载,安装,上传以及管理
-
~ 包 : 模块
-
本地模块
全局模块 -
-
设置node环境配置:
-
cache : 下载缓存
prefix : 指定全局模块的存储位置(第三方下载模块的默认 存储地址)npm config ls -l 查看配置
node_global : 设置全局模块的文件夹
node_cache : 缓存文件夹-
cache
npm config set cache “路径”
D:\Program Files\node-v10.16.0-win-x64\node_global\node_cache (临时缓存)
npm config set prefix “路径” (会自动创建一个node_modules文件夹)
D:\Program Files\node-v10.16.0-win-x64\node_global 全局模块的路径- 该国内的厂库地址(ali)
下载安装cnpm = npm (将厂库地址改为国内的)
npm install cnpm -g --registry=https://registry.npm.taobao.org - npm安装软件
- npm install 软件名称 -g/–save-dev
- cnpm install …
- cnpm install mysql -g
现在全局查找是否存在指定模块
如果要项目去全局模块中使用必须配置NODE_PATH环境变量
D:\Program Files\node-v10.16.0-win-x64\node_global\node_modules
node_path - 该国内的厂库地址(ali)
-
-
NPM 初始化项目包管理文件
package.json : 描述项目信息,包依赖信息
~ npm init -y : 安装默认配置生成 package.json文件
npm init
~ E:\node_project\webpack>npm init
This utility will walk you through creating a package.json file.
It only covers the most common items, and tries to guess sensible defaults.
~ See npm help json
for definitive documentation on these fields
and exactly what they do.
~ Use npm install <pkg>
afterwards to install a package and
save it as a dependency in the package.json file.
~ Press ^C at any time to quit.
包名,项目名称.默认安装当前文件夹名称生成
package name: (webpack)
版本号
version: (1.0.0)
项目描述
description: this is npm init
程序入口
entry point: (index.js)
测试模块
test command:
git厂库地址
git repository:
关键字
keywords:
作者
author: wuyu
开源协议
license: (ISC)
通过上面配置,生成下面的代码是否保存
About to write to E:\node_project\webpack\package.json:
{
"name": "webpack",
"version": "1.0.0",
"description": "this is npm init",
"main": "index.js",
"scripts": {
"test": "echo \"Error: no test specified\" && exit 1"
},
"author": "wuyu",
"license": "ISC"
}
~ 输入yes将生成上面的文件
Is this OK? (yes)
~ 当需要为当前项目一次性下载所有模块
npm install :会自动找当前项目下的package.json文件,读取包依赖进行下载
~ webpack
程序入口: 默认webpage编译的时候会从src下面寻找js文件
~ webpack.config.js : 配置文件
package.json : 依赖包管理
src : 编写源代码
node_modules : node 本地模块文件
dist : 编译后的文件位置