# Node.js ネイティブ API の使用

Eagleプラグインは、Node.jsのネイティブAPIをサポートしているため、次の利点が得られます：

* データ処理、ファイル圧縮、ネットワーク通信など、複雑な機能を実現するためにNode.jsの強力な機能を活用できます。
* 既存のNode.jsエコシステム内のさまざまなモジュールやライブラリを使用して、アプリケーションのさまざまな機能を迅速に実装し、車輪の再発明を避けることができます。
* Node.jsはWindows、macOSでも非常に良好なサポートがあるため、クロスプラットフォームアプリケーションを構築できます。

## 例 <a href="#oedfw" id="oedfw"></a>

```javascript
const fs = require('fs');

// ファイルを読み込む
fs.readFile('/path/to/file.txt', (err, data) => {
    if (err) throw err;
    console.log(data);
});

// ファイルに書き込む
fs.writeFile('/path/to/file.txt', 'Hello, world!', (err) => {
    if (err) throw err;
    console.log('The file has been saved!');
});

```

このコードは、ファイルを読み取り、ファイルにテキストを書き込むことができます。読み取りおよび書き込み操作が実行されると、コンソールに対応する情報が出力されます。

`fs`モジュールの他にも、Node.jsのネイティブAPIには、一連の一般的な機能を提供する多くの実用的なモジュールがあります。以下は、一般的なNode.jsのネイティブモジュールのいくつかです：

1. `http` モジュール: HTTPサーバーおよびクライアント機能を提供します。
2. `path` モジュール: ファイルパスを処理するユーティリティ関数を提供します。
3. `os` モジュール: オペレーティングシステム情報の取得機能を提供します。
4. `crypto` モジュール: 暗号化および復号化機能を提供します。
5. `zlib` モジュール: データ圧縮および解凍機能を提供します。

## 学習リソースのおすすめ <a href="#unfm7" id="unfm7"></a>

Node.jsのネイティブAPIを使用することで、アプリケーションプロセスの柔軟性と機能性が大幅に向上します。Node.js初心者の場合は、次のチュートリアルが役立ちます：

* MDNのNode.js入門チュートリアル： <https://developer.mozilla.org/zh-CN/docs/Learn/Server-side/Express_Nodejs/Introduction>
* Traversy Mediaの「Node.js Tutorial for Beginners」： <https://www.youtube.com/watch?v=TlB_eWDSMt4>
* freeCodeCampの『Node.js基礎チュートリアル | 30分でNode.jsの基本を学ぶ』：<https://www.youtube.com/watch?v=w-7RQ46RgxU>
* The Net Ninjaの『初心者向けNode.jsチュートリアル』：<https://www.youtube.com/watch?v=w-7RQ46RgxU>

上記の動画は、Node.js開発の基本を素早く学び、Node.jsの基本知識や実用的な技術を理解するのに役立ちます。


---

# Agent Instructions: Querying This Documentation

If you need additional information that is not directly available in this page, you can query the documentation dynamically by asking a question.

Perform an HTTP GET request on the current page URL with the `ask` query parameter:

```
GET https://developer.eagle.cool/plugin-api/ja-jp/tutorial/node-js-native-api.md?ask=<question>
```

The question should be specific, self-contained, and written in natural language.
The response will contain a direct answer to the question and relevant excerpts and sources from the documentation.

Use this mechanism when the answer is not explicitly present in the current page, you need clarification or additional context, or you want to retrieve related documentation sections.
