npm更新到特定版本(和shrinkwrap)

时间:2021-11-27 07:27:10

I'm using NPM and shrinkwrap (latest up to date version) to maintain my packages.

我正在使用NPM和shrinkwrap(最新版本)来维护我的包。

At the moment, one of my package current version is 1.1.0. The latest version of this package is 2.2.0.

目前,我的包当前版本中有一个是1.1.0。这个包的最新版本是2.2.0。

I want to update/upgrade this specific package to version 2.0.0 (and not the latest 2.2.0).

我想更新/升级这个特定的包到版本2.0.0(而不是最新的2.2.0)。

I thought that the procedure would be:

我认为程序应该是:

  1. npm install in order to make sure that I'm synchronized with the npm-shrinkwrap
  2. npm安装是为了确保我与npm收缩包装同步
  3. npm update myPackage@2.0.0
  4. npm更新myPackage@2.0.0
  5. npm shrinkwrap
  6. npm收缩包装
  7. git add . && git commit -m "Updating package myPackage to version 2.0.0"
  8. git添加。&& mygit提交-m“将包更新到2.0.0版本”

This doesn't seem to be the right road to go. It doesn't update the package.json and it always jump to the latest version. I have no control over this command to select the specific version I want.

这似乎不是正确的道路。它不会更新包。它总是跳转到最新的版本。我无法控制这个命令来选择我想要的特定版本。

I read the documentation about npm update and couldn't find the proper way to update the package to a specific version.

我阅读了关于npm更新的文档,但没有找到将包更新到特定版本的正确方法。

How to do this ? Would npm install --save myPackage@2.0.0 would be the correct procedure ? Then what will be the purpose of having npm update command ?

怎么做呢?npm安装——保存myPackage@2.0.0是正确的程序吗?那么拥有npm更新命令的目的是什么呢?

Solution: npm install package@2.0.0 --save

解决方案:npm安装package@2.0.0——save

2 个解决方案

#1


3  

npm update doesn't seem to interact with the shrinkwrap file as far as I can tell. But you can use npm install to set the version of a package.

据我所知,npm更新似乎并没有与shrinkwrap文件进行交互。但是您可以使用npm安装来设置包的版本。

This will update both package.json and npm-shrinkwrap.json:

这将更新这两个包。json和npm-shrinkwrap.json:

npm install myPackage@2.0.0 --save

npm安装myPackage@2.0.0,保存

#2


1  

You can enter to package.jsonand write the version yourself on the dependencies. After that do npm install and it will install the correct version.

您可以输入包。jsonand自己在依赖项上编写版本。然后进行npm安装,它将安装正确的版本。

#1


3  

npm update doesn't seem to interact with the shrinkwrap file as far as I can tell. But you can use npm install to set the version of a package.

据我所知,npm更新似乎并没有与shrinkwrap文件进行交互。但是您可以使用npm安装来设置包的版本。

This will update both package.json and npm-shrinkwrap.json:

这将更新这两个包。json和npm-shrinkwrap.json:

npm install myPackage@2.0.0 --save

npm安装myPackage@2.0.0,保存

#2


1  

You can enter to package.jsonand write the version yourself on the dependencies. After that do npm install and it will install the correct version.

您可以输入包。jsonand自己在依赖项上编写版本。然后进行npm安装,它将安装正确的版本。