Install the InfluxDB JavaScript client library

    1. Start a new Node.js project. The package manager is included with Node.js.

    Many of the client library examples use TypeScript. Follow these steps to initialize the TypeScript project.

    1. Install TypeScript and type definitions for Node.js.

      1. npm i -g typescript && npm i --save-dev @types/node
    2. Run the TypeScript compiler. To recompile your code automatically as you make changes, pass the watch flag to the compiler.

      1. tsc -w -p

    The JavaScript client library contains two packages: @influxdata/influxdb-client and . Add both as dependencies of your project.

    1. Install @influxdata/influxdb-client-apis for access to the InfluxDB management APIs:

      1. npm install --save @influxdata/influxdb-client-apis

    The client examples include an module for accessing your InfluxDB properties from environment variables or from env.js. The examples use these properties to interact with the InfluxDB API.

    1. Set environment variables or update with your InfluxDB bucket, , token, and .

      Replace the following:

      • YOUR_API_TOKEN: InfluxDB API token
      • YOUR_ORG: InfluxDB organization ID
      • YOUR_BUCKET: InfluxDB bucket name