exa-labs / exa-js

MIT License
42 stars 10 forks source link

Can't instantiate Metaphor #9

Closed Potrock closed 10 months ago

Potrock commented 10 months ago

Unable to instantiate Metaphor

This expression is not constructable.
 Type 'typeof import("node_modules/metaphor-node/dist/index")' has no construct signatures.ts(2351)

How I'm importing and instantiating:

import Metaphor from "metaphor-node";

const metaphor = new Metaphor(process.env.METAPHOR_API_KEY);

Node v18.16.0

Package.json:

{
  "name": "synthmedia-worker",
  "version": "1.0.0",
  "main": "index.js",
  "type": "module",
  "scripts": {
    "test": "echo \"Error: no test specified\" && exit 1",
    "start": "node -r dotenv/config dist/index.js"
  },
  "keywords": [],
  "author": "",
  "license": "ISC",
  "devDependencies": {
    "@types/node": "^20.4.2",
    "@types/node-cron": "^3.0.8",
    "@types/react": "^18.2.25",
    "prisma": "^5.0.0",
    "ts-node": "^10.9.1",
    "typescript": "^5.1.6"
  },
  "dependencies": {
    "@clerk/clerk-sdk-node": "^4.12.1",
    "@prisma/client": "^5.0.0",
    "@react-email/components": "^0.0.7",
    "@react-email/render": "^0.0.7",
    "@sendgrid/mail": "^7.7.0",
    "axios": "^1.5.1",
    "bullmq": "^4.6.0",
    "dayjs": "^1.11.9",
    "dotenv": "^16.3.1",
    "langchain": "^0.0.118",
    "metaphor-node": "^1.0.22",
    "node-cron": "^3.0.2",
    "puppeteer": "^19.11.1"
  },
  "description": ""
}

tsconfig:

{
    "compilerOptions": {
        "jsx": "react",
        "target": "ESNext",
        "module": "ESNext",
        "moduleResolution": "NodeNext",
        "esModuleInterop": true,
        "allowSyntheticDefaultImports": true,
        "forceConsistentCasingInFileNames": true,
        "strict": true,
        "skipLibCheck": true,
        "outDir": "./dist"
    }
}
jiito commented 10 months ago

Hi @Potrock! Thanks for raising the issue. Are you able to modify your tsconfig to use moduleResolution: 'commonjs'. I'll continue investigating how we can make metaphor-node compatible with nodenext, but for now, please let me know if this fixes your issue.

Potrock commented 10 months ago

Hi @Potrock! Thanks for raising the issue. Are you able to modify your tsconfig to use moduleResolution: 'commonjs'. I'll continue investigating how we can make metaphor-node compatible with nodenext, but for now, please let me know if this fixes your issue.

This works. Thanks @jiito .