nomic-ai / ts-nomic

Typescript bindings for Atlas
MIT License
4 stars 4 forks source link

Error [ERR_PACKAGE_PATH_NOT_EXPORTED]: No "exports" main defined in /node_modules/@nomic-ai/atlas/package.json #70

Open jonknyc opened 2 months ago

jonknyc commented 2 months ago

I am trying out this SDK as follows:

import { embed } from "@nomic-ai/atlas"

if (!process.env.NOMIC_API_KEY) {
  throw new Error("NOMIC_API_KEY is required")
}

export async function getNomicTextEmbeddings(input: string[]) {
  const result = await embed(
    input,
    {
      model: "nomic-embed-text-v1.5",
    },
    process.env.NOMIC_API_KEY,
  )
  return result
}

getNomicTextEmbeddings(["Hello world!"]).then(console.log)

but I'm getting the following error:

> tsx --require dotenv/config lib/nomic.ts

node:internal/modules/esm/resolve:302
  return new ERR_PACKAGE_PATH_NOT_EXPORTED(
         ^

Error [ERR_PACKAGE_PATH_NOT_EXPORTED]: No "exports" main defined in /Users/jonk/celebrate/node_modules/@nomic-ai/atlas/package.json
    at exportsNotFound (node:internal/modules/esm/resolve:302:10)
    at packageExportsResolve (node:internal/modules/esm/resolve:592:13)
    at resolveExports (node:internal/modules/cjs/loader:596:36)
    at Module._findPath (node:internal/modules/cjs/loader:673:31)
    at Module._resolveFilename (node:internal/modules/cjs/loader:1135:27)
    at resolve (/Users/jonk/celebrate/node_modules/tsx/dist/register-CCR7NebB.cjs:2:554)
    at resolveRequest (/Users/jonk/celebrate/node_modules/tsx/dist/register-CCR7NebB.cjs:1:2758)
    at /Users/jonk/celebrate/node_modules/tsx/dist/register-CCR7NebB.cjs:2:583
    at m._resolveFilename (file:///Users/jonk/celebrate/node_modules/tsx/dist/register-Cehy_bZS.mjs:1:789)
    at Module._load (node:internal/modules/cjs/loader:990:27) {
  code: 'ERR_PACKAGE_PATH_NOT_EXPORTED'
}

Node.js v21.6.0

it seems like perhaps the ts-nomic library needs to be updated - any ideas?

jonknyc commented 2 months ago

FYI: As a short-term workaround, I am able to get it to work by importing through node-modules directly:

import { embed } from "@/node_modules/@nomic-ai/atlas/dist/embedding.js"