# Node JS Client initialize

**URL:** https://community.influxdata.com/t/node-js-client-initialize/58214
**Category:** InfluxDB 2
**Tags:** getting-started
**Created:** [January 3, 2026, 5:22pm UTC](https://community.influxdata.com/t/node-js-client-initialize/58214 "2026-01-03T17:22:22Z")
**Posts on this page:** 4
**Page:** 1

<div class="post-metadata">

### Author: ![jspv](https://avatars.discourse-cdn.com/v4/letter/j/9fc348/32.png) [@jspv](https://community.influxdata.com/u/jspv)
#### Post date: [January 3, 2026, 5:22pm UTC](https://community.influxdata.com/t/node-js-client-initialize/58214/1 "2026-01-03T17:22:22Z")

</div>

This is what I get:

const client = new InfluxDB({localhost:1881, YvaWtjRk7lisdwbtZfXn30VhyqW8LBoweKLIv2DAt9dJlVtdAv4dRCHkYdbJv5d1JLY26Qy-Wnb8J1J9S\_gOag==})  
^

Uncaught SyntaxError: Unexpected token ‘-’

What am I doing wrong?

---

<div class="post-metadata">

### Author: ![anti\_spam\_bot](https://sea1.discourse-cdn.com/flex023/user_avatar/community.influxdata.com/anti_spam_bot/32/18549_2.png) [@anti\_spam\_bot](https://community.influxdata.com/u/anti_spam_bot)
#### Post date: [January 3, 2026, 5:22pm UTC](https://community.influxdata.com/t/node-js-client-initialize/58214/2 "2026-01-03T17:22:24Z")

</div>



---

<div class="post-metadata">

### Author: ![system](https://us1.discourse-cdn.com/flex023/uploads/influxdata/original/3X/2/f/2feb065bdfd5e4b7728243aa3b9192ad3e8447c1.png) [@system](https://community.influxdata.com/u/system)
#### Post date: [January 5, 2026, 12:22pm UTC](https://community.influxdata.com/t/node-js-client-initialize/58214/3 "2026-01-05T12:22:03Z")

</div>



---

<div class="post-metadata">

### Author: ![suyash](https://sea1.discourse-cdn.com/flex023/user_avatar/community.influxdata.com/suyash/32/15791_2.png) [@suyash](https://community.influxdata.com/u/suyash)
#### Post date: [January 5, 2026, 12:29pm UTC](https://community.influxdata.com/t/node-js-client-initialize/58214/4 "2026-01-05T12:29:04Z")

</div>

In your node.js code, you’re passing the token string raw which is incorrect, you need to pass it as strings. Here is one way to do it and also you can also store the ‘values’ as environment variables and pass those instead of hard coding it.

`import { InfluxDB } from '@influxdata/influxdb-client'`

`const influxDB = new InfluxDB({`  
` url: '``http://localhost:8086``',`  
` token: 'YOUR_API_TOKEN'`  
`}`
