Files
freeCodeCamp/curriculum/challenges/chinese/05-apis-and-microservices/managing-packages-with-npm/use-the-tilde-character-to-always-use-the-latest-patch-version-of-a-dependency.chinese.md
Beau Carnes 6b1992ee7c fix: Add Api challenges - Chinese translation (#35164)
* fix: Add Api challenges - Chinese translation

* fix: md formatting

* fix: md formatting
2019-05-06 06:31:26 -05:00

2.1 KiB
Raw Blame History

id, title, localeTitle, challengeType
id title localeTitle challengeType
587d7fb5367417b2b2512c02 Use the Tilde-Character to Always Use the Latest Patch Version of a Dependency 使用Tilde-Character始终使用依赖项的最新修补程序版本 2

Description

0在上一次挑战中我们告诉npm只包含特定版本的软件包。如果您需要确保项目的不同部分保持彼此兼容那么这是一种冻结依赖关系的有用方法。但在大多数用例中您不希望错过错误修复因为它们通常包含重要的安全补丁并且希望不会破坏这样做。 0要允许npm依赖项更新到最新的PATCH版本可以使用波形符为依赖项的版本添加前缀。在package.json中我们关于npm如何升级时刻的当前规则是仅使用特定版本2.10.2但我们希望允许最新的2.10.x版本。 0示例 "some-package-name": "~1.3.8" allows updates to any 1.3.x version. 0指令0使用波形符为依赖项中的时刻版本添加前缀并允许npm将其更新为任何新的PATCH版本。 0请注意,不应更改版本号本身。

Instructions

Tests

tests:
  - text: '“依赖”应该包括“时刻”'
    testString: 'getUserInput => $.get(getUserInput(''url'') + ''/_api/package.json'').then(data => { var packJson = JSON.parse(data); assert.property(packJson.dependencies, ''moment'', ''"dependencies" does not include "moment"''); }, xhr => { throw new Error(xhr.responseText); })'
  - text: '“时刻”版本应匹配“~2.10.2”'
    testString: 'getUserInput => $.get(getUserInput(''url'') + ''/_api/package.json'').then(data => { var packJson = JSON.parse(data); assert.match(packJson.dependencies.moment, /^\~2\.10\.2/, ''Wrong version of "moment". It should be ~2.10.2''); }, xhr => { throw new Error(xhr.responseText); })'

Challenge Seed

Solution

// solution required