pgvector / pgvector-node

pgvector support for Node.js, Deno, and Bun (and TypeScript)
MIT License
335 stars 11 forks source link

Can not import in a nestjs application #7

Closed mystist closed 1 year ago

mystist commented 1 year ago

error TS2307: Cannot find module 'pgvector/utils' or its corresponding type declarations.

3 import pgvector from 'pgvector/utils'

mystist commented 1 year ago

In my case, I need to change import path into this in package.json file:

    "./src/utils": {
      "types": "./types/utils/index.d.ts",
      "default": "./src/utils/index.js"
    },

Instead of

    "./utils": {
      "types": "./types/utils/index.d.ts",
      "default": "./src/utils/index.js"
    },
ankane commented 1 year ago

Hi @Mystist, make sure you're on the latest version of package (0.1.4). You shouldn't need to change exports.

mystist commented 1 year ago

@ankane Issue still, I can confirm that I am with the latest version.

FYI. I am import it from a service of a Nestjs application: import pgvector from 'pgvector/src/utils'

And here is my tsconfig.json:

{
  "compilerOptions": {
    "module": "commonjs",
    "declaration": true,
    "removeComments": true,
    "emitDecoratorMetadata": true,
    "experimentalDecorators": true,
    "allowSyntheticDefaultImports": true,
    "target": "es2017",
    "sourceMap": true,
    "outDir": "./dist",
    "baseUrl": "./",
    "incremental": true,
    "skipLibCheck": true,
    "strictNullChecks": false,
    "noImplicitAny": false,
    "strictBindCallApply": false,
    "forceConsistentCasingInFileNames": false,
    "noFallthroughCasesInSwitch": false
  }
}
ankane commented 1 year ago

The import statement should be:

import pgvector from 'pgvector/utils';

https://github.com/pgvector/pgvector-node#prisma

mystist commented 1 year ago

import pgvector from 'pgvector/utils';

It was this value in the beginning when I tried this. That's not the point, actually the code are fairly simple and I can copy/paste it as it is in my codebase.

Thanks for your great work!

CallumVass commented 1 year ago

Can confirm this doesnt work for me either, using 0.14 of the library.

Cannot find module 'pgvector/utils' or its corresponding type declarations.ts(2307)

pattobrien commented 1 year ago

The import statement should be:

import pgvector from 'pgvector/utils';

https://github.com/pgvector/pgvector-node#prisma

FYI this also doesn't work for me, using the latest 0.1.4 version. Like the above commenters, I can only import from "pgvector/src/utils".

ankane commented 1 year ago

Hi all, previous releases required moduleResolution to be set to node16/nodenext. Version 0.1.5 now supports node, which should fix the import errors.