content/shared/influxdb-client-libraries-reference/v2/javascript/nodejs/install.md
Install Node.js.
Ensure that InfluxDB is running and you can connect to it. For information about what URL to use to connect to your {{% product-name omit=" Clustered" %}} cluster, contact your InfluxData account representative.
In your terminal, create a directory for your Node.js project and change to it.
mkdir influx-node-app && cd influx-node-app
Enter the following command to generate an npm package for your project.
npm: the package manager included with Node.js-y: uses defaults for the package and bypasses promptsnpm init -y
Many of the client library examples use TypeScript. Follow these steps to initialize the TypeScript project:
Install TypeScript and type definitions for Node.js.
npm i -g typescript && npm i --save-dev @types/node
Enter the following command to create a TypeScript configuration
(tsconfig.json) with default values:
tsc --init
Run the TypeScript compiler.
To recompile your code automatically as you make changes, pass the --watch, -w flag to the compiler.
tsc --watch
Use the @influxdata/influxdb-client JavaScript client library to write data in {{% product-name %}}.
Open a new terminal window and install the @influxdata/influxdb-client package for querying and writing data:
npm i --save @influxdata/influxdb-client
The @influxdata/influxdb-client-apis client library package won't work with {{% product-name %}}.
It only works with InfluxDB v2 management APIs.
The client examples include an env module for accessing your InfluxDB properties from environment variables or from env.js.
The examples use these properties to interact with the InfluxDB API.
Set environment variables or update env.js with your InfluxDB database, organization (required, but ignored), database token, and cluster URL.
export INFLUX_URL=https://{{< influxdb/host >}}
export INFLUX_TOKEN=DATABASE_TOKEN
export INFLUX_ORG=ORG_ID
export INFLUX_DATABASE=DATABASE_NAME
Replace the following:
DATABASE_TOKEN: InfluxDB database tokenORG_ID: An arbitrary string (InfluxDB ignores this credential, but the client library requires it)DATABASE_NAME: InfluxDB database nameOnce you've installed the client library and configured credentials, you're ready to write data to InfluxDB.
{{< page-nav next="/influxdb3/version/reference/client-libraries/v2/javascript/nodejs/write/" keepTab=true >}}