# Pinecone is not a constructor Error

**URL:** <https://community.pinecone.io/t/pinecone-is-not-a-constructor-error/6011>\
**Category:** Support\
**Tags:** vector-database\
**Created:** [June 28, 2024, 11:08pm UTC](https://community.pinecone.io/t/pinecone-is-not-a-constructor-error/6011 "2024-06-28T23:08:45Z")\
**Posts on this page:** 3\
**Page:** 1

<div class="post-metadata">

**Author:** ![kevinsuntopdev](https://sea2.discourse-cdn.com/flex020/user_avatar/community.pinecone.io/kevinsuntopdev/32/466_2.png) [@kevinsuntopdev](https://community.pinecone.io/u/kevinsuntopdev)\
**Post date:** [June 28, 2024, 11:08pm UTC](https://community.pinecone.io/t/pinecone-is-not-a-constructor-error/6011/1 "2024-06-28T23:08:45Z")

</div>

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

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

    return pinecone;
  } catch (error) {
    console.log("error", error);
  }
}

export const pinecone = await initPinecone();

```

Migrating to new Pinecone version “@pinecone-database/pinecone”: “^2.2.2”, in Next JS and keep getting error

```auto
 TypeError: _pinecone_database_pinecone __WEBPACK_IMPORTED_MODULE_0__.Pinecone is not a constructor

```

Any help is appreciated, thanks.

---

<div class="post-metadata">

**Author:** ![ZacharyProser](https://sea2.discourse-cdn.com/flex020/user_avatar/community.pinecone.io/zacharyproser/32/1146_2.png) [@ZacharyProser](https://community.pinecone.io/u/ZacharyProser)\
**Post date:** [July 1, 2024, 3:01pm UTC](https://community.pinecone.io/t/pinecone-is-not-a-constructor-error/6011/2 "2024-07-01T15:01:35Z")

</div>

Hi @kevinsuntopdev, and welcome to the Pinecone community forums!

Thank you for your question.

Given that you’re using Next.js, does the error persist if you kill the hosting process `npm run dev` and delete your `.next` folder in the same directory then restart local dev mode with `npm run dev`?

I sometimes see that exact Webpack error in a transient manner for a variety of different libraries.

I also have [a sample TypeScript repo here where I’ve set up Pinecone](https://github.com/zackproser/pinecone-create-index-typescript/blob/main/app/api/init-pinecone/pinecone.js) that you could reference.

I’ll update it now to use the latest Pinecone client version that you’re running and see if I have any issues…

---

<div class="post-metadata">

**Author:** ![ZacharyProser](https://sea2.discourse-cdn.com/flex020/user_avatar/community.pinecone.io/zacharyproser/32/1146_2.png) [@ZacharyProser](https://community.pinecone.io/u/ZacharyProser)\
**Post date:** [July 1, 2024, 3:14pm UTC](https://community.pinecone.io/t/pinecone-is-not-a-constructor-error/6011/3 "2024-07-01T15:14:09Z")

</div>

Hi @kevinsuntopdev,

I just updated my sample repo which I linked above to use the exact same version of the Pinecone client that you’re running, and my Pinecone client was successfully instantiated and my repo created the target index correctly.

Therefore, my current best recommendations are:

1. Clean up your `.next` folder and restart your app to see if it was indeed a transient Webpack error
2. See if using the patterns [here](https://github.com/zackproser/pinecone-create-index-typescript/blob/main/app/api/init-pinecone/pinecone.js)2. changes anything for you.

Hope that helps!

Best,  
Zack
