> ## Documentation Index
> Fetch the complete documentation index at: https://translations.mintlify.site/llms.txt
> Use this file to discover all available pages before exploring further.

> Auth0 Actions 内で依存関係をインストールして管理する方法を説明します。

# 依存関係の管理

Actions では、[`npm` レジストリ](https://www.npmjs.com/)のパッケージを使用できます。Actions の依存関係は、<Tooltip tip="Auth0 Dashboard: サービスを設定するための Auth0 のメイン製品です。" cta="用語集を表示" href="/ja/docs/glossary?term=Auth0+Dashboard">Auth0 Dashboard</Tooltip> の Actions Code Editor または Auth0 <Tooltip tip="Auth0 Dashboard: サービスを設定するための Auth0 のメイン製品です。" cta="用語集を表示" href="/ja/docs/glossary?term=Management+API">Management API</Tooltip> を使用してインストールおよび管理できます。

<div id="add-a-dependency-using-the-actions-code-editor">
  ## Actions Code Editor を使用して依存関係を追加する
</div>

公開 `npm` レジストリのパッケージへの依存関係を追加するには、次の手順に従います。

1. [Auth0 Dashboard > Actions > Library](https://manage.auth0.com/#/actions/library) に移動し、対象の Action を選択します。
2. Actions Code Editor で、サイドバーの Modules (キューブアイコン) を選択します。
3. **Add Module** を選択し、モジュール名を入力します。パッケージの利用可能な最新バージョンを使用する場合は、version フィールドは空欄のままにできます。
4. Actions のコードで、モジュールを require します。たとえば Axios パッケージを追加した場合は、Actions Code Editor 内のコードの先頭に次の行を追加します。

   ```javascript lines theme={null}
   const axios = require('axios');
   ```

<div id="add-a-dependency-using-the-auth0-management-api">
  ## Auth0 Management API を使用して依存関係を追加する
</div>

または、Auth0 Management API の [Create Action endpoint](https://auth0.com/docs/api/management/v2#!/Actions/post_action) を使って依存関係を追加することもできます。エンドポイントを呼び出す際は、ペイロードに依存関係を指定します。

```bash lines theme={null}
curl -H "Authorization: Bearer {managementApiToken}" \
     -X POST  -H "Content-Type: application/json" \
     -d '{ \
            "name":"my-action", \
            "supported_triggers":[{"id":"post-login","version":"v2"}], \
            "code":"module.exports = () => {}",\
            "dependencies": [{\
                "name":"lodash",\
                "version":"4.17.21"\
            }],\
            "runtime":"node14"\
        }' \
    https://{yourTenant}.com/api/v2/actions/actions
```

<div id="security-considerations">
  ## セキュリティに関する考慮事項
</div>

サードパーティ製パッケージには脆弱性や悪意のあるコードが含まれる可能性があるため、Actions で使用する前にパッケージを監査することを推奨します。また、ソフトウェア構成分析ツールを使用して、パッケージの脆弱性を継続的に監視することも推奨します。

<div id="limitations-for-dependencies-in-actions">
  ## Actions で使用する依存関係の制限事項
</div>

<div id="no-native-module-support">
  ### ネイティブモジュールはサポートされていません
</div>

Actions ではネイティブモジュールを使用できません。ネイティブモジュールに依存する Action を実行すると、`Compilation failed: Cannot find module` を含むエラーメッセージが表示されます。

`npm` パッケージがネイティブかどうかを確認するには、その `npm` パッケージの公開 GitHub リポジトリに移動し、サイドバーでコードに使用されている言語を確認します。使用言語に C/C++ が含まれている場合、そのパッケージはネイティブモジュールである可能性が高いです。代表的な例として、`bcrypt` や `sqlite3` があります。

<div id="no-private-module-or-private-registry-support">
  ### プライベートモジュールまたはプライベートレジストリには対応していません
</div>

Actions では、プライベート `npm` モジュールとプライベート `npm` レジストリは使用できません。Actions では[公開 `npm` レジストリ](https://registry.npmjs.org)を使用します。
