Files
freeCodeCamp/curriculum/challenges/japanese/05-back-end-development-and-apis/managing-packages-with-npm/use-the-caret-character-to-use-the-latest-minor-version-of-a-dependency.md
2022-01-20 20:30:18 +01:00

2.4 KiB

id, title, challengeType, forumTopicId, dashedName
id title challengeType forumTopicId dashedName
587d7fb5367417b2b2512c03 キャレット文字を使用して依存関係の最新の MINOR バージョンを使用する 2 301531 use-the-caret-character-to-use-the-latest-minor-version-of-a-dependency

--description--

前回のチャレンジで学んだチルダと同じように、npm では依存関係の最新の PATCH をインストールできます。npm でキャレット (^) を使用すると、将来のアップデートもインストールできます。 両者の違いは、キャレットでは MINOR アップデートと PATCH の両方が可能であることです。

moment の現在のバージョンを「~2.10.2」にすると、npm で最新の 2.10.x バージョンをインストールできます。 代わりにバージョン プレフィックスとしてキャレット (^) を使用すると、npm では任意の 2.x.x バージョンへ更新できます。

"package": "^1.3.8"

この記述では、パッケージを任意の 1.x.x バージョンへ更新できます。

--instructions--

依存関係内の moment のバージョンのプレフィックスとしてキャレット (^) を使用し、npm によって任意の新しい MINOR リリースへ更新できるようにしてください。

注: バージョン番号自体は変更しないでください。

--hints--

「dependencies」に「moment」を含める必要があります。

(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);
    }
  );

「moment」バージョンは、「^2.x.x」と一致する必要があります。

(getUserInput) =>
  $.get(getUserInput('url') + '/_api/package.json').then(
    (data) => {
      var packJson = JSON.parse(data);
      assert.match(
        packJson.dependencies.moment,
        /^\^2\./,
        'Wrong version of "moment". It should be ^2.10.2'
      );
    },
    (xhr) => {
      throw new Error(xhr.responseText);
    }
  );

--solutions--

/**
  Backend challenges don't need solutions, 
  because they would need to be tested against a full working project. 
  Please check our contributing guidelines to learn more.
*/