如何在node.js中更新量角器npm模块?

时间:2021-06-17 07:27:47

I am using Visual Studio 2013 Node.js Tools for Visual Studio.

我正在使用Visual Studio 2013 Node.js工具用于Visual Studio。

I would like to update protractor to this:

我想更新量角器到这个:

https://www.npmjs.org/package/protractor

Under npm in Visual Studio I see it shows I have the protractor@0.24.2 module. When I right click on this and select

在Visual Studio的npm下,我看到它显示我有protractor@0.24.2模块。当我右键单击此并选择时

update npm module

It goes to

它去了

https://registry.npmjs.org/protractor

When I enter that in my URL it shows on the the first line 1.0.0-rc2 as the latest version:

当我在我的URL中输入它时,它在第一行1.0.0-rc2上显示为最新版本:

https://registry.npmjs.org/protractor

{"_id":"protractor","_rev":"103-dc957e08fce862ad70c481b4a2327ee6",
"name":"protractor","description":"Webdriver E2E test wrapper for Angular.",
"dist-tags":{"latest":"1.0.0-rc2"},
"versions":{"0.1.0":{"name":"protractor",
"description":"End to End test helpers for Angular.",
"homepage":"https://github.com/juliemr/protractor","keywords":

In the output window it shows the update:

在输出窗口中,它显示更新:

====Executing command 'npm update protractor --save'====


npm http GET https://registry.npmjs.org/protractor
npm http 304 https://registry.npmjs.org/protractor
npm http GET https://registry.npmjs.org/selenium-webdriver
npm http GET https://registry.npmjs.org/jasminewd
npm http GET https://registry.npmjs.org/glob
npm http GET https://registry.npmjs.org/saucelabs
npm http GET https://registry.npmjs.org/adm-zip
npm http GET https://registry.npmjs.org/optimist
npm http GET https://registry.npmjs.org/lodash
npm http GET https://registry.npmjs.org/q
npm http GET https://registry.npmjs.org/source-map-support
npm http 304 https://registry.npmjs.org/selenium-webdriver
npm http 304 https://registry.npmjs.org/jasminewd
npm http 304 https://registry.npmjs.org/saucelabs
npm http 304 https://registry.npmjs.org/optimist
npm http 304 https://registry.npmjs.org/q
npm http 304 https://registry.npmjs.org/glob
npm http 304 https://registry.npmjs.org/adm-zip
npm http 304 https://registry.npmjs.org/lodash
npm http 304 https://registry.npmjs.org/source-map-support
npm http GET https://registry.npmjs.org/inherits
npm http GET https://registry.npmjs.org/minimatch
npm http GET https://registry.npmjs.org/wordwrap
npm http GET https://registry.npmjs.org/minimist
npm http GET https://registry.npmjs.org/source-map
npm http 304 https://registry.npmjs.org/inherits
npm http 304 https://registry.npmjs.org/minimatch
npm http 304 https://registry.npmjs.org/wordwrap
npm http 304 https://registry.npmjs.org/minimist
npm http 304 https://registry.npmjs.org/source-map
npm http GET https://registry.npmjs.org/lru-cache
npm http GET https://registry.npmjs.org/sigmund
npm http 304 https://registry.npmjs.org/lru-cache
npm http 304 https://registry.npmjs.org/sigmund
npm http GET https://registry.npmjs.org/amdefine
npm http 304 https://registry.npmjs.org/amdefine
protractor@0.24.2 node_modules\protractor
├── jasminewd@1.0.1
├── saucelabs@0.1.1
├── q@1.0.0
├── adm-zip@0.4.4
├── optimist@0.6.1 (wordwrap@0.0.2, minimist@0.0.10)
├── lodash@2.4.1
├── glob@3.2.11 (inherits@2.0.1, minimatch@0.3.0)
├── source-map-support@0.2.7 (source-map@0.1.32)
└── selenium-webdriver@2.42.0

====npm command completed with exit code 0====

What I would like to know is if the first line shows 1.0.0-rc2 as the latest version then why does it still show protractor 0.24.2 as the one that it downloaded after the update?

我想知道的是,如果第一行显示1.0.0-rc2作为最新版本,为什么它仍然显示量角器0.24.2作为它在更新后下载的那个?

1 个解决方案

#1


18  

The "npm update" command doesn't actually upgrade packages unconditionally. It simply upgrades packages to the maximum allowed semver as noted in the package.json file for your dependencies and their sub dependencies. To actually upgrade to a newer version you have two options:

“npm update”命令实际上不会无条件地升级包。它只是将包升级到最大允许的semver,如package.json文件中所述,用于依赖项及其子依赖项。要实际升级到更新版本,您有两个选择:

  1. Use "npm install" and specify the version to install. You can use the "latest" tag to specify the latest version without having to look it up. Use the "--save" flag to have npm edit your package.json file and update to the new version.

    使用“npm install”并指定要安装的版本。您可以使用“最新”标签指定最新版本,而无需查找。使用“--save”标志让npm编辑package.json文件并更新到新版本。

    npm install protractor@latest --save

    npm安装量角器@ latest --save

  2. Edit the package.json and find the line with "protractor": "0.24.2" and change the version to "1.0.0-rc2" (or whichever version you want). Then you can run "npm update" or "npm install" after you have changed and saved the file.

    编辑package.json并找到带有“protractor”的行:“0.24.2”并将版本更改为“1.0.0-rc2”(或您想要的任何版本)。然后,您可以在更改并保存文件后运行“npm update”或“npm install”。

#1


18  

The "npm update" command doesn't actually upgrade packages unconditionally. It simply upgrades packages to the maximum allowed semver as noted in the package.json file for your dependencies and their sub dependencies. To actually upgrade to a newer version you have two options:

“npm update”命令实际上不会无条件地升级包。它只是将包升级到最大允许的semver,如package.json文件中所述,用于依赖项及其子依赖项。要实际升级到更新版本,您有两个选择:

  1. Use "npm install" and specify the version to install. You can use the "latest" tag to specify the latest version without having to look it up. Use the "--save" flag to have npm edit your package.json file and update to the new version.

    使用“npm install”并指定要安装的版本。您可以使用“最新”标签指定最新版本,而无需查找。使用“--save”标志让npm编辑package.json文件并更新到新版本。

    npm install protractor@latest --save

    npm安装量角器@ latest --save

  2. Edit the package.json and find the line with "protractor": "0.24.2" and change the version to "1.0.0-rc2" (or whichever version you want). Then you can run "npm update" or "npm install" after you have changed and saved the file.

    编辑package.json并找到带有“protractor”的行:“0.24.2”并将版本更改为“1.0.0-rc2”(或您想要的任何版本)。然后,您可以在更改并保存文件后运行“npm update”或“npm install”。