1

I followed the docs: https://github.com/pinecone-io/pinecone-ts-client

I installed it via:

npm install @pinecone-database/pinecone

I've also set the following environmental variables:

PINECONE_API_KEY="your_api_key"
PINECONE_ENVIRONMENT="your_environment"

And then I have:

const PineconeClient = require('@pinecone-database/pinecone')
const pinecone = new PineconeClient();

But I'm getting the error:

TypeError - PineconeClient is not a constructor

Why is that the case? I'm following the docs but I'm getting the error?

The version of pinecone I have:

"@pinecone-database/pinecone": "^1.1.2"

And my node version is:

v20.9.0
4
  • 2
    const {Pinecone:PineconeClient} = require('@pinecone-database/pinecone') because the same docs has a sample snippet where the class is an attribute inside of what is imported... essentially, destructuring Commented Oct 30, 2023 at 0:12
  • How do I go about fixing it then? Commented Oct 30, 2023 at 0:30
  • 1
    the example snippet should make calling new PineconeClient() work ;-; as it is an example of destructuring it with the variable name you desire... conversely you can also do const PineconeClient = require('@pinecone-database/pinecone').Pinecone as well Commented Oct 30, 2023 at 0:34
  • 1
    .... @mark did you try what was suggested by the bomb squad? That's the solution you should try. Commented Oct 30, 2023 at 0:35

2 Answers 2

0

This worked.

const {Pinecone:PineconeClient} = require('@pinecone-database/pinecone') const pinecone = new PineconeClient({ apiKey: "key"});

Sign up to request clarification or add additional context in comments.

Comments

0

The code below seems to work so far with no errors

import { Pinecone } from "@pinecone-database/pinecone";

let pinecone;

export async function initPinecone() {
  pinecone = new Pinecone({
    apiKey: process.env.PINECONE_API_KEY,
  });

  console.log("Pinecone initialized successfully.");
}

Comments

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge you have read our privacy policy.

Start asking to get answers

Find the answer to your question by asking.

Ask question

Explore related questions

See similar questions with these tags.