webpack

65 篇文章 0 订阅
64 篇文章 0 订阅
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 : 缓存文件夹

  1. 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 全局模块的路径

    1. 该国内的厂库地址(ali)
      下载安装cnpm = npm (将厂库地址改为国内的)
      npm install cnpm -g --registry=https://registry.npm.taobao.org
    2. npm安装软件
      1. npm install 软件名称 -g/–save-dev
      2. cnpm install …
      3. cnpm install mysql -g

    现在全局查找是否存在指定模块
    如果要项目去全局模块中使用必须配置NODE_PATH环境变量
    D:\Program Files\node-v10.16.0-win-x64\node_global\node_modules
    node_path

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 : 编译后的文件位置

  • 0
    点赞
  • 0
    收藏
    觉得还不错? 一键收藏
  • 0
    评论

“相关推荐”对你有帮助么?

  • 非常没帮助
  • 没帮助
  • 一般
  • 有帮助
  • 非常有帮助
提交
评论
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

当前余额3.43前往充值 >
需支付:10.00
成就一亿技术人!
领取后你会自动成为博主和红包主的粉丝 规则
hope_wisdom
发出的红包
实付
使用余额支付
点击重新获取
扫码支付
钱包余额 0

抵扣说明:

1.余额是钱包充值的虚拟货币,按照1:1的比例进行支付金额的抵扣。
2.余额无法直接购买下载,可以购买VIP、付费专栏及课程。

余额充值