Background
The js-langchain template depends on hnswlib-node (via HNSWLib from @langchain/community/vectorstores/hnswlib), which is a native C++ addon compiled with node-gyp at install time.
On Windows without a node-gyp–compatible Visual Studio toolchain, npm install fails:
npm error path .../node_modules/hnswlib-node
npm error command ... node-gyp rebuild
gyp ERR! find VS could not find a version of Visual Studio 2017 or newer to use
gyp ERR! stack Error: Could not find any Visual Studio installation to use
This surfaced in CI when the windows-latest runner image moved to Visual Studio 18 (2026), which the bundled node-gyp can't detect. It also affects real users on Windows who don't have the "Desktop development with C++" workload installed.
CI mitigation already in place
The LLM-AI-node test workflow is pinned to windows-2022 (which ships VS 2022 that node-gyp supports) as a stopgap. That only fixes CI — it does not fix the install for end users, and windows-2022 is on GitHub's deprecation path.
Proposed fix — drop the native dependency
Replace the native HNSWLib vector store with a pure-JS store so the template installs on any platform with no C++ toolchain.
- Swap
HNSWLib for a pure-JS vector store (e.g. MemoryVectorStore from langchain/vectorstores/memory), or another store that doesn't require a native build.
- Remove
hnswlib-node from package.json.
- Rework
src/vector_index_cache.js: it currently tars HNSWLib's on-disk index directory into the vector-index-cache key-value store and untars it back. MemoryVectorStore has no save(path)/load(path) on-disk format, so the index caching must either be re-implemented (e.g. serialize the in-memory vectors to JSON in the KV store) or dropped.
Files involved
templates/js-langchain/src/main.js — HNSWLib.fromDocuments / vectorStore.save / HNSWLib.load
templates/js-langchain/src/vector_index_cache.js — persistence/caching layer
templates/js-langchain/package.json — drop hnswlib-node
Considerations / open questions
- This is user-facing example code. Moving to an in-memory store changes what the template demonstrates and likely degrades or removes the "cache the vector index between runs" feature. We should decide whether to preserve caching (via JSON serialization) or accept its removal.
- Persistent-but-pure-JS options in LangChain JS are limited (FAISS is also native; Chroma/PGVector need a server), which is why MemoryVectorStore + custom JSON caching is the most likely path.
Acceptance criteria
npm install for js-langchain succeeds on Windows with no Visual Studio / C++ build tools.
- Template runs end-to-end on
ubuntu and windows-latest.
- Once merged, revert the
windows-2022 pin in .github/workflows/test_llm_ai_node_templates.yaml back to windows-latest.
Background
The
js-langchaintemplate depends onhnswlib-node(viaHNSWLibfrom@langchain/community/vectorstores/hnswlib), which is a native C++ addon compiled withnode-gypat install time.On Windows without a node-gyp–compatible Visual Studio toolchain,
npm installfails:This surfaced in CI when the
windows-latestrunner image moved to Visual Studio 18 (2026), which the bundlednode-gypcan't detect. It also affects real users on Windows who don't have the "Desktop development with C++" workload installed.CI mitigation already in place
The LLM-AI-node test workflow is pinned to
windows-2022(which ships VS 2022 that node-gyp supports) as a stopgap. That only fixes CI — it does not fix the install for end users, andwindows-2022is on GitHub's deprecation path.Proposed fix — drop the native dependency
Replace the native HNSWLib vector store with a pure-JS store so the template installs on any platform with no C++ toolchain.
HNSWLibfor a pure-JS vector store (e.g.MemoryVectorStorefromlangchain/vectorstores/memory), or another store that doesn't require a native build.hnswlib-nodefrompackage.json.src/vector_index_cache.js: it currently tars HNSWLib's on-disk index directory into thevector-index-cachekey-value store and untars it back.MemoryVectorStorehas nosave(path)/load(path)on-disk format, so the index caching must either be re-implemented (e.g. serialize the in-memory vectors to JSON in the KV store) or dropped.Files involved
templates/js-langchain/src/main.js—HNSWLib.fromDocuments/vectorStore.save/HNSWLib.loadtemplates/js-langchain/src/vector_index_cache.js— persistence/caching layertemplates/js-langchain/package.json— drophnswlib-nodeConsiderations / open questions
Acceptance criteria
npm installforjs-langchainsucceeds on Windows with no Visual Studio / C++ build tools.ubuntuandwindows-latest.windows-2022pin in.github/workflows/test_llm_ai_node_templates.yamlback towindows-latest.