[转] 合理使用npm version与npm dist-tag详解

第一步:发布第一个稳定版本

 npm publish//1.0.0

第二步:修改文件继续发布第二个版本

git add -A && git commit -m "c"
npm version patch
npm publish//1.0.1

第三步:继续修改文件发布一个prerelease版本

 git add -A && git commit -m "c"
 npm version prerelease
 npm publish --tag -beta//版本[email protected]

第四步:继续修改发布第二个prerelease版本

git add -A && git commit -m "c"
npm version prerelease
npm publish --tag beta//版本[email protected]

第五步:npm info查看我们的版本信息

{ name: ‘n-n-n-n‘,
  ‘dist-tags‘: { latest: ‘1.0.1‘, ‘-beta‘: ‘1.0.2-1‘ },
  versions: [ ‘1.0.0‘, ‘1.0.1‘, ‘1.0.2-0‘, ‘1.0.2-1‘ ],
  maintainers: [ ‘liangklfang <[email protected]>‘ ],
  time:
   { modified: ‘2017-04-01T12:17:56.755Z‘,
     created: ‘2017-04-01T12:15:23.605Z‘,
     ‘1.0.0‘: ‘2017-04-01T12:15:23.605Z‘,
     ‘1.0.1‘: ‘2017-04-01T12:16:24.916Z‘,
     ‘1.0.2-0‘: ‘2017-04-01T12:17:23.354Z‘,
     ‘1.0.2-1‘: ‘2017-04-01T12:17:56.755Z‘ },
  homepage: ‘https://github.com/liangklfang/n#readme‘,
  repository: { type: ‘git‘, url: ‘git+https://github.com/liangklfang/n.git‘ },
  bugs: { url: ‘https://github.com/liangklfang/n/issues‘ },
  license: ‘ISC‘,
  readmeFilename: ‘README.md‘,
  version: ‘1.0.1‘,
  description: ‘‘,
  main: ‘index.js‘,
  scripts: { test: ‘echo "Error: no test specified" && exit 1‘ },
  author: ‘‘,
  gitHead: ‘8123b8addf6fed83c4c5edead1dc2614241a4479‘,
  dist:
   { shasum: ‘a60d8b02222e4cae74e91b69b316a5b173d2ac9d‘,
     tarball: ‘https://registry.npmjs.org/n-n-n-n/-/n-n-n-n-1.0.1.tgz‘ },
  directories: {} }

我们只要注意下面者两个部分:

 ‘dist-tags‘: { latest: ‘1.0.1‘, ‘-beta‘: ‘1.0.2-1‘ },
  versions: [ ‘1.0.0‘, ‘1.0.1‘, ‘1.0.2-0‘, ‘1.0.2-1‘ ],

其中最新的稳定版本和最新的beta版本可以在dist-tags中看到,而versions数组中存储的是所有的版本。

第六步:npm dist-tag命令

npm dist-tag ls n-n-n-n

即npm dist-tag获取到所有的最新的版本,包括prerelease与稳定版本,得到下面结果:

-beta: 1.0.2-1
latest: 1.0.1

第七步:当我们的prerelease版本已经稳定了,重新设置为稳定版本

npm dist-tag add [email protected]1.0.2-1 latest

此时你通过npm info查看可以知道:

{ name: ‘n-n-n-n‘,
  ‘dist-tags‘: { latest: ‘1.0.2-1‘, ‘-beta‘: ‘1.0.2-1‘ },
  versions: [ ‘1.0.0‘, ‘1.0.1‘, ‘1.0.2-0‘, ‘1.0.2-1‘ ],
  maintainers: [ ‘liangklfang <[email protected]>‘ ],
  time:
   { modified: ‘2017-04-01T12:24:55.800Z‘,
     created: ‘2017-04-01T12:15:23.605Z‘,
     ‘1.0.0‘: ‘2017-04-01T12:15:23.605Z‘,
     ‘1.0.1‘: ‘2017-04-01T12:16:24.916Z‘,
     ‘1.0.2-0‘: ‘2017-04-01T12:17:23.354Z‘,
     ‘1.0.2-1‘: ‘2017-04-01T12:17:56.755Z‘ },
  homepage: ‘https://github.com/liangklfang/n#readme‘,
  repository: { type: ‘git‘, url: ‘git+https://github.com/liangklfang/n.git‘ },
  bugs: { url: ‘https://github.com/liangklfang/n/issues‘ },
  license: ‘ISC‘,
  readmeFilename: ‘README.md‘,
  version: ‘1.0.2-1‘,
  description: ‘‘,
  main: ‘index.js‘,
  scripts: { test: ‘echo "Error: no test specified" && exit 1‘ },
  author: ‘‘,
  gitHead: ‘03189d2cc61604aa05f4b93e429d3caa3b637f8c‘,
  dist:
   { shasum: ‘41ea170a6b155c8d61658cd4c309f0d5d1b12ced‘,
     tarball: ‘https://registry.npmjs.org/n-n-n-n/-/n-n-n-n-1.0.2-1.tgz‘ },
  directories: {} }

主要关注如下:

 ‘dist-tags‘: { latest: ‘1.0.2-1‘, ‘-beta‘: ‘1.0.2-1‘ },
  versions: [ ‘1.0.0‘, ‘1.0.1‘, ‘1.0.2-0‘, ‘1.0.2-1‘ ]

此时latest版本已经是prerelease版本”1.0.2-1”了!此时用户如果直接运行npm install就会安装我们的prerelease版本了,因为版本已经更新了!

参考资料:

NPM模块的TAG管理

npm-dist-tag

npm-version

node-semver

原文地址:https://www.cnblogs.com/chris-oil/p/9046357.html

时间: 2024-08-30 15:53:16

[转] 合理使用npm version与npm dist-tag详解的相关文章

Dist 函数详解

1.Dist函数的算法如下(很显然该算法的本质就是常说的欧氏距离算法) R(i,j) = SQRT(F(i)^2 + G(j)^2)   where: F(i) = i  IF 0 <= i <= n/2 = n-i  IF i > n/2 G(i) = i  IF 0 <= i <= m/2 = m-i  IF i > m/2 图解:tvscl,dist(200) 扩展:SURFACE, DIST(20), /SAVE IDL实现源码: ; $Id: //depot/

npm package.json属性详解

章节目录 概述 name version description keywords homepage bugs license 和用户相关的属性: author, contributors files main bin man directories directories.lib directories.bin directories.man directories.doc directories.example repository scripts config dependencies U

npm 常用命令详解

npm是什么 NPM的全称是Node Package Manager,是随同NodeJS一起安装的包管理和分发工具,它很方便让JavaScript开发者下载.安装.上传以及管理已经安装的包. npm install 安装模块 基础语法 npm install (with no args, in package dir) npm install [<@scope>/]<name>npm install [<@scope>/]<name>@<tag>

NPM使用详解(上)

1.NPM是什么? NPM是JavaScript的包管理工具,在安装NodeJS(什么?你不知道node?来,我们合计合计:https://nodejs.org/)的时候,会自动安装上npm. 要查看安装的npm版本,只需要打开cmd控制台,输入npm -v NPM使得JavaScript开发者分享和重用代码非常容易,同时也让你能否非常方便的更新你分享的代码. NPM能够自己升级自己,使用命令如下: npm install npm -g 2.NPM的使用 以下代码示例中:<>表示必选参数,[]

NPM使用详解(下)

*:first-child { margin-top: 0 !important; } body>*:last-child { margin-bottom: 0 !important; } /* BLOCKS =============================================================================*/ p, blockquote, ul, ol, dl, table, pre { margin: 15px 0; } /* HEAD

npm + gulp 项目构成详解

一.npm讲解 https://www.npmjs.com.cn/ NPM是随同NodeJS一起安装的包管理工具,能解决NodeJS代码部署上的很多问题,常见的使用场景有以下几种: 允许用户从NPM服务器下载别人编写的第三方包到本地使用. 允许用户从NPM服务器下载并安装别人编写的命令行程序到本地使用. 允许用户将自己编写的包或命令行程序上传到NPM服务器供别人使用. 由于nodejs已经集成了npm,所以npm也一并安装好了.同样可以通过输入 "npm -v" 来测试是否成功安装.

Windows系统下nodejs、npm、express的下载和安装教程详解

这篇文章主要介绍了Windows系统下nodejs.npm.express的下载和安装教程详解,非常不错,具有参考借鉴价值,需要的朋友可以参考下1. node.js下载 首先进入http://nodejs.org/dist/,这里面的版本呢,几乎每个月都出几个新的,建议大家下载最新版本,看看自己的电脑是多少位的,别下错了. 下载完解压到你想放的位置就好了,解压后你会发现里面有node.exe.我解压到了D:\software_install婴儿起名http://www.bbqmw.net/qm_

nodeJs中npm详解

npm 是 Node.js 的模块依赖管理工具.作为开发者使用的工具,主要解决开发 node.js 时会遇到的问题.如同 RubyGems 对于 Ruby 开发者和 Maven 对于 Java 开发者的重要性,npm 对与 Node.js 的开发者和社区的重要性不言而喻.本文包括五点:package.json .npm 的配置.npm install 命令.npm link 命令和其它 npm 命令. package.json npm命令运行时会读取当前目录的 package.json 文件和解

npm install 和npm start各种报错无法解决的问题

记一次npm install 和npm start各种报错的问题,个人理解,如若有错请指证 ***npm install下载速度缓慢,会中途终止怎么办? 答:1.安装淘宝镜像,npm  config set registry https://registry.npm.taobao.org --global    npm config set disturl https://npm.taobao.org/dist --global 由于npm是国外服务器,所以安装这个之后会快很多,或者是安装cnp