Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Error when running example code for mxpx-openai-node - SyntaxError: Cannot use import statement outside a module #3

Open
notnotrishi opened this issue Jan 8, 2025 · 2 comments

Comments

@notnotrishi
Copy link

/Users/rishi/Projects/mcpx-openai-chat/index.js:2 import { McpxOpenAI } from "@dylibso/mcpx-openai"; ^^^^^^

SyntaxError: Cannot use import statement outside a module at internalCompileFunction (node:internal/vm:77:18) at wrapSafe (node:internal/modules/cjs/loader:1288:20) at Module._compile (node:internal/modules/cjs/loader:1340:27) at Module._extensions..js (node:internal/modules/cjs/loader:1435:10) at Module.load (node:internal/modules/cjs/loader:1207:32) at Module._load (node:internal/modules/cjs/loader:1023:12) at Function.executeUserEntryPoint [as runMain] (node:internal/modules/run_main:135:12) at node:internal/main/run_main_module:28:49

For now, in order to fix it and run, I added type as module in package.json and renamed index.js to index.mjs (i guess either should work?)

{
  "name": "mcpx-openai-chat",
  "version": "1.0.0",
  "type": "module",
  "description": "",
  "main": "index.js",
  "scripts": {
    "test": "echo \"Error: no test specified\" && exit 1"
  },
  "keywords": [],
  "author": "",
  "license": "ISC",
  "dependencies": {
    "@dylibso/mcpx-openai": "^0.0.2",
    "openai": "^4.77.3",
    "pino": "^9.6.0",
    "pino-pretty": "^13.0.0"
  }
}

Node version is: v21.1.0

@nilslice
Copy link
Member

nilslice commented Jan 8, 2025

Thank you! cc/ @bhelx

@bhelx
Copy link
Contributor

bhelx commented Jan 21, 2025

Apologies i never got back to this thread. I think we were backchanneling. I think should be able to upgrade node or change the file extension to .mjs. I'm going to see about changing the example so it works with all versions of node.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

3 participants