2、Vue实战-配置篇-npm配置
引言:
如果刚开始使用 vue 并不了解 nodejs、npm 相关知识可以看我上一篇的实践,快速入门了解实战知识树。
上篇反思:
1、新的关注点:开发 vue 模板、如何使用本地 vue 模板。
2、关于学习:
1、学习不能急于求成,要有计划、有前瞻性、知识体系要完整。
2、学习不能马虎,要透过现象看本质。要将遇到的问题归纳分类,举一反三,提升分析问题的能力。
3、要根据自己情况定义 学习粒度 并和实际情况结合起来形成具有个人特色的策略性思维。
正文:
Vue实战-配置篇-npm
1、npm 配置 package.json 文件。
使用命令 npm init 创建一个新的 package.json 文件。
如图:

: 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 j son for definitive documentation on these fields and exactly what they do. package. json npm help json se npm install (pkg) - afterwards to install a package and save it as a dependency in the package. json file. x ress "C at any time to quit. ackage name: (npm) npminittest version: (1. 0. 0) description: npm init test entry point: (index. js) entrypointjs. npm install hQ8 git test command: git repository: keywords : author: zws license: (ISC) bout to write to C: \ npminittest" name . • ". "1.0. o", verslon "descri tion . n m init m ackage. J son: test" " src="file:///C:/Users/18410/Desktop/%E6%96%B0%E5%BB%BA%E6%96%87%E4%BB%B6%E5%A4%B9/Vue%E5%AE%9E%E6%88%98.files/image002.jpg" v:shapes="图片_x0020_1">
根据提示 执行 npm help json 命令 跳转到 npm 官网的帮助页面(本地html文件)。
如图我看到了:它的行为受npm-config 的影响。

于是紧跟着跳转准备参阅 npm-config。

你妹啊,不是可能比我想的多,是真的好多啊,不看了。。。有用的时候再查吧。。。
回头看 package.json 介绍 前面是命名规则建议之类的就不多提了,如果命名有问题会有提示的。
例:不能以点开头。

此例可以看出来 重复执行的 npm init 相当于修改。
然后是一些字段的介绍。
1、main

2、bin 设置环境变量,如果你要贡献的话需要了解一下。
比如 执行了 npm install vue@vue-cli 以后就可以在命令行调用 vue 命令了。
3、scripts 注册包各个生命周期要运行的脚本,但是我发现key是可以自定义的,比如 dist ,然后
Npm run dist 暂时记下回头再研究。

4、config 将执行 start npm_package_config_+key,这块内容比较复杂,回头再研究。

5、dependencies 依赖。
- version Must match version exactly
- >version Must be greater than version
- >=version etc
- <version
- <=version
- ~version "Approximately equivalent to version" See semver(7)
- ^version "Compatible with version" See semver(7)
- 1.2.x 1.2.0, 1.2.1, etc., but not 1.3.0
- http://... See 'URLs as Dependencies' below
- * Matches any version
- "" (just an empty string) Same as *
- version1 - version2 Same as >=version1 <=version2.
- range1 || range2 Passes if either range1 or range2 are satisfied.
- git... See 'Git URLs as Dependencies' below
- user/repo See 'GitHub URLs' below
- tag A specific version tagged and published as tag See npm-dist-tag(1)
- path/path/path See Local Paths below
For example, these are all valid:
{ "dependencies" :
{ "foo" : "1.0.0 - 2.9999.9999"
, "bar" : ">=1.0.2 <2.1.2"
, "baz" : ">1.0.2 <=2.3.4"
, "boo" : "2.0.1"
, "qux" : "<1.0.0 || >=2.3.1 <2.4.5 || >=2.5.2 <3.0.0"
, "asd" : "http://asdf.com/asdf.tar.gz"
, "til" : "~1.2"
, "elf" : "~1.2.3"
, "two" : "2.x"
, "thr" : "3.3.x"
, "lat" : "latest"
, "dyl" : "file:../dyl"
}
}
粘过来方便查看。
6、DEFAULT VALUES 一些缺省值

(url) format, where email and url are optional. Lines which start
with a S or are blank, will be ignored. " src="file:///C:/Users/18410/Desktop/%E6%96%B0%E5%BB%BA%E6%96%87%E4%BB%B6%E5%A4%B9/Vue%E5%AE%9E%E6%88%98.files/image016.jpg" border="0" v:shapes="图片_x0020_8">
现阶段需要了解这些就够了。
最后,npm 官网入门里有一节 understanding packages and modules推荐阅读。
2、Vue实战-配置篇-npm配置的更多相关文章
- [ASP.NET Core开发实战]基础篇06 配置
配置,是应用程序很重要的组成部分,常常用于提供信息,像第三方应用登录钥匙.上传格式与大小限制等等. ASP.NET Core提供一系列配置提供程序读取配置文件或配置项信息. ASP.NET Core项 ...
- 1、Vue 实战-入门篇
先决条件:需要 Node.js . npm 基础. 如果没有基础看先看下面简单的两点介绍. 1.npm 命令介绍. 1.所有命令 -h 可以查看.也可以从官网查 docs,结果如下. --help ...
- Hadoop学习18--yarn配置篇-基本配置节点
<configuration> <property> <name>yarn.nodemanager.aux-services</name> <va ...
- iView 实战系列教程(21课时)_1.iView 实战教程之配置篇
1.iView 实战教程之配置篇 点击添加插件,. 选中后安装 全部导入还是按需导入. 2.是否需要自定义主题变量 3.多语言的设置. 这里我们全部选择为默认 然后点击继续. 启动项目 入口文件导入了 ...
- webpack构建vue项目(配置篇)
最近公司要求用vue重构项目,还涉及到模块化开发,于是乎,我专门花了几天的时间研究了一下webpack这个目前来看比较热门的模块加载兼打包工具,发现上手并不是很容易,现将总结的一些有关配置的心得分享出 ...
- Vue + Webpack + Vue-loader 系列教程(2)相关配置篇
原文地址:https://lvyongbo.gitbooks.io/vue-loader/content/ 使用预处理器 在 Webpack 中,所有的预处理器需要和一个相应的加载器一同使用.vue- ...
- spring boot实战(第十三篇)自动配置原理分析
前言 spring Boot中引入了自动配置,让开发者利用起来更加的简便.快捷,本篇讲利用RabbitMQ的自动配置为例讲分析下Spring Boot中的自动配置原理. 在上一篇末尾讲述了Spring ...
- webpack3.x版本实战案例【基础配置篇】(一)
本文旨在通过一个一个实战例子来学习webpack如何配置,更加深入的学习webpack在实战项目中如何配置. 我们学习哪些配置呢? [基础配置] 打包JS 编译ES6 编译typeScript 打包公 ...
- vue爬坑之路(webpack 配置篇)
在vue cli下 1.npm run dev 打开浏览器在config的index.js中修改autoOpenBrowser为true 关闭sourcemap productionSourceMap ...
随机推荐
- Math.abs( x )
Math.abs( x ) 下面是参数的详细信息: x : 一个数字 返回值: 返回一个数字的绝对值 <html> <head> <title>JavaScript ...
- H3C 查看RIP的debugging信息
- H3C 静态黑洞路由应用
- 【踩坑记录】vue单个组件内<style lang="stylus" type="text/stylus" scoped>部分渲染失效
vue组件化应用,近期写的单个组件里有一个的渲染部分样式渲染不上去 因为同结构的其他组件均没有问题,所以排除是.vue文件结构的问题,应该是<style>内部的问题 <style l ...
- H3C通过端口ID决定端口角色
- <% %>、<%! %>和<%= %>
<% %> 此标签内的内容在jsp编译的时候,将被编译成servlet的_jspService()方法.这个方法用作服务器端向客户端输出.因此这对标签里边不能在定义方法了,因为在Java ...
- PowerShell 拿到最近的10个系统日志
我最近发现我的程序总是调用一些不清真的代码,于是在运行的时候就退出了,我想要拿到系统的日志知道我的程序是怎么退出的,我如何通过 PowerShell 拿到最近的10个系统日志.为什么需要拿到最新10个 ...
- PowerShell 通过 WMI 获取系统服务
本文告诉大家如何通过 WMI 获取系统服务 通过 Win32_Service 可以获取系统启动的服务 Get-WmiObject Win32_Service | Format-List Caption ...
- HDU6581 Vacation (HDU2019多校第一场1004)
HDU6581 Vacation (HDU2019多校第一场1004) 传送门:http://acm.hdu.edu.cn/showproblem.php?pid=6581 题意: 给你n+1辆汽车, ...
- 关于oppo和vivo这两年强势崛起的反思
先来谈谈配置吧(小白跳过) oppo产品线 r7 67522015年05月3g2320mAh r7 p 6795 6153g4100mAh r7s 616 67522015年10月4g 3070mAh ...