npm knowledge basics
npm inro
https://www.npmjs.com/
npm is the package manager for javascript
npm 为 nodejs默认的包管理工具, 为nodejs软件内置。
安装nodejs后, 使用 npm install xxx 可以安装第三方软件库
对于开发者自己建立一个npm工程, 使用npm init完成。
demo
各个参数解读,见官方文档:
https://docs.npmjs.com/files/package.json#version
{"name": "dijistra","version": "1.0.4","description": "a simple dijistra implementation of js version","main": "./dist/dijistra.umd.js","scripts": {"build": "webpack --config webpack-config.js","publish": "npm publish","lint": "eslint src"},"keywords": ["dijistra", "algorithm"],"author": "lightsong","license": "MIT","repository": {"type": "git","url": "https://github.com/fanqingsong/dijistra_algorithm"},"devDependencies": {"babel-core": "^6.9.1","babel-eslint": "^6.0.4","babel-loader": "^6.2.4","babel-plugin-syntax-dynamic-import": "^6.18.0","babel-preset-es2015": "^6.9.0","babel-preset-stage-2": "^6.5.0","css-loader": "^0.23.1","eslint": "^2.12.0","eslint-config-airbnb-base": "^3.0.1","eslint-plugin-babel": "^3.2.0","html-webpack-plugin": "^2.21.0","style-loader": "^0.13.1","webpack": "^3.5.4","webpack-dev-server": "^1.14.1"},"dependencies": {"pleasejs": "^0.4.2"}}
版本号含义
版本号的格式有多种, 支持各种需求场景。
默认 npm install --save-dev xxx 是按照兼容格式来 ^ x.xx.xx
https://docs.npmjs.com/files/package.json#dependency
See semver for more details about specifying version ranges.
version
Must matchversion
exactly>version
Must be greater thanversion
>=version
etc<version
<=version
~version
“Approximately equivalent to version” See semver^version
“Compatible with version” See semver1.2.x
1.2.0, 1.2.1, etc., but not 1.3.0http://...
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’ belowuser/repo
See ‘GitHub URLs’ belowtag
A specific version tagged and published astag
Seenpm-dist-tag
path/path/path
See Local Paths below
详细说明:
https://docs.npmjs.com/misc/semver
Hyphen Ranges X.Y.Z - A.B.C§
Specifies an inclusive set.
1.2.3 - 2.3.4
:=>=1.2.3 <=2.3.4
X-Ranges 1.2.x 1.X 1.2.* *§
Any of
X
,x
, or*
may be used to “stand in” for one of the numeric values in the[major, minor, patch]
tuple.
*
:=>=0.0.0
(Any version satisfies)1.x
:=>=1.0.0 <2.0.0
(Matching major version)1.2.x
:=>=1.2.0 <1.3.0
(Matching major and minor versions)Tilde Ranges ~1.2.3 ~1.2 ~1§
Allows patch-level changes if a minor version is specified on the comparator. Allows minor-level changes if not.
~1.2.3
:=>=1.2.3 <1.(2+1).0
:=>=1.2.3 <1.3.0
~1.2
:=>=1.2.0 <1.(2+1).0
:=>=1.2.0 <1.3.0
(Same as1.2.x
)~1
:=>=1.0.0 <(1+1).0.0
:=>=1.0.0 <2.0.0
(Same as1.x
)~0.2.3
:=>=0.2.3 <0.(2+1).0
:=>=0.2.3 <0.3.0
~0.2
:=>=0.2.0 <0.(2+1).0
:=>=0.2.0 <0.3.0
(Same as0.2.x
)~0
:=>=0.0.0 <(0+1).0.0
:=>=0.0.0 <1.0.0
(Same as0.x
)~1.2.3-beta.2
:=>=1.2.3-beta.2 <1.3.0
Note that prereleases in the1.2.3
version will be allowed, if they are greater than or equal tobeta.2
. So,1.2.3-beta.4
would be allowed, but1.2.4-beta.2
would not, because it is a prerelease of a different[major, minor, patch]
tuple.Caret Ranges ^1.2.3 ^0.2.5 ^0.0.4§
Allows changes that do not modify the left-most non-zero digit in the
[major, minor, patch]
tuple. In other words, this allows patch and minor updates for versions1.0.0
and above, patch updates for versions0.X >=0.1.0
, and no updates for versions0.0.X
.Many authors treat a
0.x
version as if thex
were the major “breaking-change” indicator.Caret ranges are ideal when an author may make breaking changes between
0.2.4
and0.3.0
releases, which is a common practice. However, it presumes that there will not be breaking changes between0.2.4
and0.2.5
. It allows for changes that are presumed to be additive (but non-breaking), according to commonly observed practices.
^1.2.3
:=>=1.2.3 <2.0.0
^0.2.3
:=>=0.2.3 <0.3.0
^0.0.3
:=>=0.0.3 <0.0.4
^1.2.3-beta.2
:=>=1.2.3-beta.2 <2.0.0
Note that prereleases in the1.2.3
version will be allowed, if they are greater than or equal tobeta.2
. So,1.2.3-beta.4
would be allowed, but1.2.4-beta.2
would not, because it is a prerelease of a different[major, minor, patch]
tuple.^0.0.3-beta
:=>=0.0.3-beta <0.0.4
Note that prereleases in the0.0.3
version only will be allowed, if they are greater than or equal tobeta
. So,0.0.3-pr.2
would be allowed.
npm发布
https://www.jianshu.com/p/d9fb02a891d9
先到官网上注册, 然后使用邮箱确认。
本地登录,输入完用户名,密码,邮箱后没有错误信息就完成了。
$ npm adduser
Username: your name
Password: your password
Email: (this IS public) your email
要设置一个版本号
npm社区版本号规则采用的是semver(语义化版本),主要规则版本格式:主版本号.次版本号.修订号,版本号递增规则如下:
- 主版本号:当你做了不兼容的 API 修改,
- 次版本号:当你做了向下兼容的功能性新增,
- 修订号:当你做了向下兼容的问题修正。
先行版本号及版本编译信息可以加到“主版本号.次版本号.修订号”的后面,作为延伸。
发布
npm publish
// 需要设置库URLnpm config set registry=http://registry.npmjs.org
例子:
https://www.npmjs.com/package/dijistra
npm knowledge basics的更多相关文章
- Oracle DBA神器之Toad
很早就听说Toad功能很强大,一直没有使用过,因为PLSQL Developer就很好用.前几天看见同事优化Oracle就是用的Toad,有一些很强大的管理功能,于是再一次对Toad产生兴趣,收集了一 ...
- [转载]Frontend Knowledge Structure
https://github.com/JacksonTian/fks http://code.csdn.net/news/2819224 本文为大家整理了一系列关于JavaScript的常用工具,包括 ...
- npm run dev error
Please try: rm -rf node_modules rm package-lock.json npm cache clear --force npm install windows和lin ...
- Entity Framework Tutorial Basics(1):Introduction
以下系列文章为Entity Framework Turial Basics系列 http://www.entityframeworktutorial.net/EntityFramework5/enti ...
- ACM-ICPC2018沈阳网络赛 Lattice's basics in digital electronics(模拟)
Lattice's basics in digital electronics 44.08% 1000ms 131072K LATTICE is learning Digital Electron ...
- Basics of Algorithmic Trading: Concepts and Examples
https://www.investopedia.com/articles/active-trading/101014/basics-algorithmic-trading-concepts-and- ...
- upc组队赛15 Lattice's basics in digital electronics【模拟】
Lattice's basics in digital electronics 题目链接 题目描述 LATTICE is learning Digital Electronic Technology. ...
- Getting Started With Node and NPM
Getting Started with Node and NPM Let's start with the basics. Install Node.js: https://nodejs.org.
- npx & yarn & npm
npx & yarn & npm React Redux App https://reactjs.org/ https://github.com/facebook/create-rea ...
随机推荐
- redis -hash(哈希.对象)
hash 用于储存对象,对象的结构为属性.值 值的类型string 增加.修改: 设置单个属性: hset 键 field 值 例如: 设置键 user 的属性name 为 python hset u ...
- SQL 游标的使用
适用场景:对查询出的结果集遍历,作用类似于其他语言的列表循环语句. 相关语法: --定义游标 DECLARE cr CURSOR FOR( SELECT Cust_ID ,Cust_Name ,IDC ...
- WordPress慢的八种解决方法(用排查法解决)
WordPress的打开速度慢会影响到用户体验和关键词的稳定排名,WordPress为什么加载慢呢?其实很简单的,就是WordPress水土不服,用WordPress的大家都知道,WordPress是 ...
- MVC中使用viewmodel
新建一个类在类中写 public class DataViewmodel { public List<users> usersmodel { get; set; } public List ...
- Docker 部署Confluence15.2
一.数据库准备 数据库版本:5.7 这里数据库并没有采用docker镜像方式,而是选择已有数据库.至于数据库安装这里不再说明. 注:我这里安装confluence时,需要在下面配置数据库信息时,在数据 ...
- 深入理解SpringIOC容器
转载来源:[https://www.cnblogs.com/fingerboy/p/5425813.html] 前言: 在逛博客园的时候突然发现一篇关于事务的好文章,说起spring事物就离不开AOP ...
- delphi7 编译的程序在win7下请求获得管理员权限的方法
网上找到的,记下来方便查找,亲测此方法可用.附带把编译好的uac.res上传. 首先,用记事本新建一文本文档,内容如下: 1 24 UAC.manifest 然后另存为uac.rc 另外新建一文本档, ...
- VBS 备份文件
http://www.cnblogs.com/top5/archive/2009/11/17/1604767.html 参考上面的博客 ' =============== 局域网文件自动备份 VBS ...
- [CQOI2014]危桥
题目描述 Alice和Bob居住在一个由N座岛屿组成的国家,岛屿被编号为0到N-1.某些岛屿之间有桥相连,桥上的道路是双 向的,但一次只能供一人通行.其中一些桥由于年久失修成为危桥,最多只能通行两次. ...
- ADC采样工作原理详解
如何利用单片机的ADC模块(或者独立的ADC芯片)得到接入ADC管脚上的实际电压值?这个问题,是第一次接触ADC时候,大家都会遇到的问题.会读到什么值单片机会读到什么值?需要看一个特性,就是几位的AD ...