pinecone-ts-client: PineconeClient: Project name not set. Call init() first

Hi!

First day using Pinecone. I followed the steps at https://docs.pinecone.io/docs/node-client but I’m getting an error.

Version: 0.0.8

Code:

 const pinecone = new PineconeClient();
  await pinecone.init({
    environment: "us-east1-gcp",
    apiKey: "SECRET",
  });

  const index = pinecone.Index("websites");

  try {
    const res = await index.upsert({
      upsertRequest: {
        vectors: [
          {
            id: "1",
            values: vector,
          },
        ],
      },
    });
....

Error:

Error: PineconeClient: Project name not set. Call init() first.
    at PineconeClient.Index (./node_modules/@pinecone-database/pinecone/dist/index.js:172:19)
    at insertToVectorCollection (embeddings.js:50:28)
    at processTicksAndRejections (node:internal/process/task_queues:96:5)
    at async createIndex (index.js:77:9)

I tried setting the projectName right before the init() but didn’t make a difference:

const pinecone = new PineconeClient();
pinecone.projectName = "websites";
await pinecone.init({...

What can I do to fix problem?

Thank you.

About this issue

  • Original URL
  • State: closed
  • Created a year ago
  • Reactions: 2
  • Comments: 51 (8 by maintainers)

Commits related to this issue

Most upvoted comments

I use Node 16.17.1 and get the same error…

“Error: PineconeClient: Project name not set. Call init() first.”

anyone?

i use Node.js v18.15.0 , i also get the same error

Why is this one closed? I’m getting the same error and I’m using this langchain example here: https://js.langchain.com/docs/modules/indexes/vector_stores/integrations/pinecone#index-docs

I also did the project name workaround at first, but after some digging I understood that my environments were written wrong. here is a template.

image PINECONE_ENVIRONMENT=“eu-west1-gcp” PINECONE_INDEX_NAME=“indexname” PINECONE_API_KEY = “0000000-0000-42a9-901b-123456788”

Seems like this issue was resolved at 0.0.10 but was then reintroduced in 0.0.11?

I experienced this error, when the ‘environment’ was incorrectly set in the call to init(). I had ‘us-east-gcp’. Should have been: ‘us-east1-gcp’… Strange that the init() call did not fail, but that the error was generated from the subsequent call.

I was able to solve this problem by setting the project name after the init. Here is the code that worked for me.

I’m using Node v19.8.1, “langchain”: “^0.0.45”, and “@pinecone-database/pinecone”: “^0.0.10”.

import { PineconeClient } from '@pinecone-database/pinecone';

if (!process.env.PINECONE_ENVIRONMENT || !process.env.PINECONE_API_KEY) {
  throw new Error('Pinecone environment or api key vars missing');
}

async function initPinecone() {
  try {
    const pinecone = new PineconeClient();

    await pinecone.init({
      environment: process.env.PINECONE_ENVIRONMENT ?? '', //this is in the dashboard
      apiKey: process.env.PINECONE_API_KEY ?? '',
    });
    pinecone.projectName = 'default';

    return pinecone;
  } catch (error) {
    console.log('error', error);
    throw new Error('Failed to initialize Pinecone Client');
  }
}

export const pinecone = await initPinecone();

@rschwabco

I currently have the pinecone environment set to ‘us-central1-gcp’ because that is what is shown on my pinecone dashboard.

I’ve rotated and tried a new API key as well but am still receiving the same error on my local machine. I tested my API key & environment via Pinecone API Reference (https://docs.pinecone.io/reference/list_collections) and I was able to get a 200 response there.

@PMLS3 Yes, Im also deploying to google clouds, the problem here is that when you deploy a new installation of node_modules happens.

Want to co op in discord? my username is WhiteRhino#7935

I think you should pull the code again, there has been changes last night in the code. B/w “langchain”: “0.0.41”, is that i am using

Are you behind some proxy?

I’ve added an engines version specification to ensure this issue doesn’t resurface:

  "engines": {
    "node": ">=18.0.0"
  },