dylibso / dylibso/mcpx-openai-node

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

Open
#3 2 comments 0 reactions 0 assignees View on GitHub
Dominant language
TypeScript
Stars
15
Forks
1
PR merge metrics
No merged PRs in 30d

Description

- I tried running the example code at https://docs.mcp.run/tutorials/mcpx-openai-node
- I get the following error after running index.js
```
/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

Contributor guide

No contributing guide indexed for this repository

Assessment

This issue has not been assessed yet.

Get new issues in your inbox

A short digest of beginner-friendly GitHub issues.