Named export 'LMStudioClient' not found
import { LMStudioClient } from '@lmstudio/sdk';
When I import the SDK like this, I get the following error:
import { LMStudioClient } from '@lmstudio/sdk';
^^^^^^^^^^^^^^
SyntaxError: Named export 'LMStudioClient' not found. The requested module '@lmstudio/sdk' is a CommonJS module, which may not support all module.exports as named exports. CommonJS modules can always be imported via the default export, for example using:
import pkg from '@lmstudio/sdk';
const { LMStudioClient } = pkg;
at ModuleJob._instantiate (node:internal/modules/esm/module_job:132:21)
at async ModuleJob.run (node:internal/modules/esm/module_job:214:5)
at async ModuleLoader.import (node:internal/modules/esm/loader:329:24)
at async loadESM (node:internal/process/esm_loader:28:7)
at async handleMainPromise (node:internal/modules/run_main:113:12)
Adding /index.mjs does work though:
import { LMStudioClient } from '@lmstudio/sdk/index.mjs';
Please try again with 0.2.22 from the homepage: https://lmstudio.ai
Thanks for the report. We are still investigating how to add automatic esm support. For now, please use the 'index.mjs' entry point (as you have discovered).
import { LMStudioClient } from '@lmstudio/sdk/index.mjs';
No problem. As per the error message, this also works:
import SDK from '@lmstudio/sdk';
const { LMStudioClient } = SDK;
This may help with offering both CJS and ESM options: Create npm package with CommonJS and ESM support in TypeScript
This is now fixed since v0.3.0 - thanks team! 👍