Open henri-edh opened 4 months ago
@henri-edh Node.js 18.6.0 or newer should work. Can you please share the error you are getting?
We are using node v18.16.0, so any version above should work. Do you mind sharing the error message?
Fresh install today
import * as LMStudioClient from "@lmstudio/sdk";
console.log(LMStudioClient)
(base) quinn@kuromi:/usr/share/pool/workspace/Applications/lmstudio$ npm run start
> pkg-placeholder@0.0.0 start
> esno src/index.ts
/usr/share/pool/workspace/Applications/lmstudio/src/index.ts:1
import { LMStudioClient } from "@lmstudio/sdk";
^
SyntaxError: The requested module '@lmstudio/sdk' does not provide an export named 'LMStudioClient'
at ModuleJob._instantiate (node:internal/modules/esm/module_job:144:21)
at async ModuleJob.run (node:internal/modules/esm/module_job:227:5)
at async ModuleLoader.import (node:internal/modules/esm/loader:461:24)
at async asyncRunEntryPointWithESMLoader (node:internal/modules/run_main:119:5)
> pkg-placeholder@0.0.0 start
> esno src/index.ts
[Module: null prototype] {
BRAND: undefined,
ConnectionStatus: undefined,
DIRTY: undefined,
DiagnosticsNamespace: undefined,
EMPTY_PATH: undefined,
Holder: undefined,
INVALID: undefined,
LLMDynamicHandle: undefined,
LLMNamespace: undefined,
LLMSpecificModel: undefined,
NEVER: undefined,
OK: undefined,
OngoingPrediction: undefined,
Pager: undefined,
ParseStatus: undefined,
PredictionResult: undefined,
Schema: undefined,
Subscribable: undefined,
SystemNamespace: undefined,
Transport: undefined,
ZodAny: undefined,
ZodArray: undefined,
ZodBigInt: undefined,
ZodBoolean: undefined,
ZodBranded: undefined,
ZodCatch: undefined,
ZodDate: undefined,
ZodDefault: undefined,
ZodDiscriminatedUnion: undefined,
ZodEffects: undefined,
ZodEnum: undefined,
ZodError: undefined,
ZodFirstPartyTypeKind: undefined,
ZodFunction: undefined,
ZodIntersection: undefined,
ZodIssueCode: undefined,
ZodLazy: undefined,
ZodLiteral: undefined,
ZodMap: undefined,
ZodNaN: undefined,
ZodNativeEnum: undefined,
ZodNever: undefined,
ZodNull: undefined,
ZodNullable: undefined,
ZodNumber: undefined,
ZodObject: undefined,
ZodOptional: undefined,
ZodParsedType: undefined,
ZodPipeline: undefined,
ZodPromise: undefined,
ZodReadonly: undefined,
ZodRecord: undefined,
ZodSchema: undefined,
ZodSet: undefined,
ZodString: undefined,
ZodSymbol: undefined,
ZodTransformer: undefined,
ZodTuple: undefined,
ZodType: undefined,
ZodUndefined: undefined,
ZodUnion: undefined,
ZodUnknown: undefined,
ZodVoid: undefined,
_borderStyles: undefined,
addIssueToContext: undefined,
any: undefined,
array: undefined,
bigint: undefined,
boolean: undefined,
coerce: undefined,
createAuthenticatedClientPort: undefined,
createDiagnosticsBackendInterface: undefined,
createLlmBackendInterface: undefined,
createSystemBackendInterface: undefined,
custom: undefined,
date: undefined,
default: { LMStudioClient: [Getter] },
defaultErrorMap: undefined,
discriminatedUnion: undefined,
effect: undefined,
enum: undefined,
errorUtil: undefined,
friendlyErrorDeserializer: undefined,
function: undefined,
getErrorMap: undefined,
getParsedType: undefined,
instanceof: undefined,
intersection: undefined,
isAborted: undefined,
isAsync: undefined,
isDirty: undefined,
isValid: undefined,
jsonSerializableSchema: undefined,
late: undefined,
lazy: undefined,
literal: undefined,
llmErrorDisplayDataSchema: undefined,
logLevelSchema: undefined,
makeIssue: undefined,
map: undefined,
nan: undefined,
nativeEnum: undefined,
never: undefined,
null: undefined,
nullable: undefined,
number: undefined,
object: undefined,
objectUtil: undefined,
oboolean: undefined,
onumber: undefined,
optional: undefined,
ostring: undefined,
pipeline: undefined,
preprocess: undefined,
promise: undefined,
quotelessJson: undefined,
record: undefined,
set: undefined,
setErrorMap: undefined,
strictObject: undefined,
string: undefined,
symbol: undefined,
transformer: undefined,
tuple: undefined,
undefined: undefined,
union: undefined,
unknown: undefined,
util: undefined,
void: undefined,
wsAuthenticationResultSchema: undefined,
z: undefined
}
Looks like this is the resolution. Documentation needs to be updated: https://github.com/lmstudio-ai/lmstudio.js/issues/8
import SDK from '@lmstudio/sdk'; const { LMStudioClient } = SDK;
Seems you have figured it out. 👍
Actually, sorry, I think you might be having a different issue.
Yeah - I don't think this issue should be closed until there is an update to the docs or the exports are fixes
@QuinnPiers Hi, let's track the esm support in #8. I don't think @henri-edh is facing the same issue.
Hi @henri-edh
This error seems to be caused by installing the development environment of lmstudio.js (which has a development time dependency that doesn't support apple silicon yet).
That said, if you are not trying to contribute to lmstudio.js itself (i.e. if you just want to use lmstudio.js), you should run npm install @lmstudio/sdk
inside your own project. We actually have a guide on how to create a new project on our documentation website: https://lmstudio.ai/docs/lmstudio-sdk/quick-start, please check it out. :D
On the other hand, if you are indeed trying to contribute, you can remove "parcel" from the devDependencies section. We are currently not using parcel, so it is safe to remove.
What version of node is required ?
I have a Macbook M3 Max Apple Silicon and get errors trying to run : npm install @lmstudio/sdk
Any advice on this ?
I use a Macbook Pro M3 max:
Here is a short section of the node errors: npm error code 1 npm error path /Users/henrijohnson/Repos/lmstudio.js/node_modules/lmdb npm error command failed npm error command sh -c node-gyp-build-optional-packages npm error make: Entering directory '/Users/henrijohnson/Repos/lmstudio.js/node_modules/lmdb/build' npm error CXX(target) Release/obj.target/lmdb/src/lmdb-js.o npm error make: Leaving directory '/Users/henrijohnson/Repos/lmstudio.js/node_modules/lmdb/build' npm error /Users/henrijohnson/Repos/lmstudio.js/node_modules/node-gyp-build-optional-packages/index.js:77 npm error throw new Error('No native build was found for ' + target + '\n attempted loading from: ' + dir + ' and package:' + npm error ^ npm error npm error Error: No native build was found for platform=darwin arch=arm64 runtime=node abi=120 uv=1 armv=8 libc=glibc node=21.2.0 npm error attempted loading from: /Users/henrijohnson/Repos/lmstudio.js/node_modules/lmdb and package: @lmdb/lmdb-darwin-arm64 npm error npm error at load.path (/Users/henrijohnson/Repos/lmstudio.js/node_modules/node-gyp-build-optional-packages/index.js:77:9) npm error at load (/Users/henrijohnson/Repos/lmstudio.js/node_modules/node-gyp-build-optional-packages/index.js:29:25) npm error at Object. (/Users/henrijohnson/Repos/lmstudio.js/node_modules/node-gyp-build-optional-packages/build-test.js:19:19)
npm error at Module._compile (node:internal/modules/cjs/loader:1376:14)
npm error at Module._extensions..js (node:internal/modules/cjs/loader:1435:10)
npm error at Module.load (node:internal/modules/cjs/loader:1207:32)
npm error at Module._load (node:internal/modules/cjs/loader:1023:12)
npm error at Function.executeUserEntryPoint [as runMain] (node:internal/modules/run_main:135:12)
npm error at node:internal/main/run_main_module:28:49
npm error
npm error Node.js v21.2.0
npm error
npm error The failure above indicates the primary issue with the native builds which are included for all major platforms. Will now attempt to build the package locally in case this can be resolved by re-compiling.
npm error gyp info it worked if it ends with ok
npm error gyp info using node-gyp@10.0.1
npm error gyp info using node@21.2.0 | darwin | arm64
npm error gyp info find Python using Python version 3.12.3 found at "/opt/homebrew/opt/python@3.12/bin/python3.12"
npm error gyp info spawn /opt/homebrew/opt/python@3.12/bin/python3.12
npm error gyp info spawn args [
npm error gyp info spawn args '/Users/henrijohnson/Repos/lmstudio.js/node_modules/node-gyp/gyp/gyp_main.py',
npm error gyp info spawn args 'binding.gyp',
npm error gyp info spawn args '-f',
npm error gyp info spawn args 'make',
npm error gyp info spawn args '-I',
npm error gyp info spawn args '/Users/henrijohnson/Repos/lmstudio.js/node_modules/lmdb/build/config.gypi',
npm error gyp info spawn args '-I',
npm error gyp info spawn args '/Users/henrijohnson/Repos/lmstudio.js/node_modules/node-gyp/addon.gypi',
npm error gyp info spawn args '-I',
npm error gyp info spawn args '/Users/henrijohnson/Library/Caches/node-gyp/21.2.0/include/node/common.gypi',
npm error gyp info spawn args '-Dlibrary=shared_library',
npm error gyp info spawn args '-Dvisibility=default',
npm error gyp info spawn args '-Dnode_root_dir=/Users/henrijohnson/Library/Caches/node-gyp/21.2.0',
npm error gyp info spawn args '-Dnode_gyp_dir=/Users/henrijohnson/Repos/lmstudio.js/node_modules/node-gyp',
npm error gyp info spawn args '-Dnode_lib_file=/Users/henrijohnson/Library/Caches/node-gyp/21.2.0/<(target_arch)/node.lib',
npm error gyp info spawn args '-Dmodule_root_dir=/Users/henrijohnson/Repos/lmstudio.js/node_modules/lmdb',
npm error gyp info spawn args '-Dnode_engine=v8',
npm error gyp info spawn args '--depth=.',
npm error gyp info spawn args '--no-parallel',
npm error gyp info spawn args '--generator-output',
npm error gyp info spawn args 'build',
npm error gyp info spawn args '-Goutput_dir=.'
npm error gyp info spawn args ]
npm error gyp info spawn make
npm error gyp info spawn args [ 'BUILDTYPE=Release', '-C', 'build' ]
npm error In file included from ../src/lmdb-js.cpp:1:
npm error ../src/lmdb-js.h:4:10: fatal error: vector: No such file or directory
npm error 4 | #include
npm error | ^
~~~ npm error compilation terminated. npm error make: *** [lmdb.target.mk:161: Release/obj.target/lmdb/src/lmdb-js.o] Error 1 npm error gyp ERR! build error npm error gyp ERR! stack Error:make
failed with exit code: 2