Coder Social home page Coder Social logo

its not work on bunjs about hnswlib-node HOT 3 CLOSED

yoshoku avatar yoshoku commented on May 18, 2024
its not work on bunjs

from hnswlib-node.

Comments (3)

yoshoku avatar yoshoku commented on May 18, 2024

@ddosakura
hnsw-node also work on Bun:

// index.ts

import { BruteforceSearch, HierarchicalNSW } from 'hnswlib-node'

const numDimensions = 8;
const maxElements = 10;

const index = new HierarchicalNSW('l2', numDimensions);
index.initIndex(maxElements);

for (let i = 0; i < maxElements; i++) {
  const point = new Array(numDimensions);
  for (let j = 0; j < numDimensions; j++) point[j] = Math.random();
  index.addPoint(point, i);
}

const query = new Array(numDimensions);
for (let j = 0; j < numDimensions; j++) query[j] = Math.random();

const numNeighbors = 3;
const result = index.searchKnn(query, numNeighbors);

console.table(result);
bun_hnswlib-node

Please read the error message carefully in the screenshot of the issue:

error: Could not import hnsw-node. Please install hnsw-node as a dependency with, e. g. `npm install -S hnswlib-node`

The error probably occurred because hnswlib-node was not installed.

from hnswlib-node.

yoshoku avatar yoshoku commented on May 18, 2024

Since the original issues are closed, this issue is also closed. Thank you for your understanding.

from hnswlib-node.

ddosakura avatar ddosakura commented on May 18, 2024

Reasons for not work:

  1. Early versions of bunjs did not auto run node-gyp scripts

also see:

microsoft/node-pty#632 (comment)

This has been fixed in bun:1.1.0+:

oven-sh/bun#9289

  1. the official bunjs image not work

oven-sh/bun#9807

The issue has been closed, but the latest image still reports an error

docker run --interactive --tty --rm -v $PWD:$PWD --workdir $PWD oven/bun:1.1.3-debian /bin/bash

apt update
apt install python3

rm -rf node_modules/
bun i hnswlib-node
# gyp: name 'llvm_version' is not defined while evaluating condition 'llvm_version=="0.0"' in binding.gyp while trying to load binding.gyp

use nodejs image:

oven-sh/bun#9807 (comment)

docker run --interactive --tty --rm -v $PWD:$PWD --workdir $PWD node:20.12.1-slim /bin/bash

npm i -g bun

apt update
apt install python3 make g++

rm -rf node_modules/
bun i hnswlib-node

it works!

from hnswlib-node.

Related Issues (20)

Recommend Projects

  • React photo React

    A declarative, efficient, and flexible JavaScript library for building user interfaces.

  • Vue.js photo Vue.js

    🖖 Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.

  • Typescript photo Typescript

    TypeScript is a superset of JavaScript that compiles to clean JavaScript output.

  • TensorFlow photo TensorFlow

    An Open Source Machine Learning Framework for Everyone

  • Django photo Django

    The Web framework for perfectionists with deadlines.

  • D3 photo D3

    Bring data to life with SVG, Canvas and HTML. 📊📈🎉

Recommend Topics

  • javascript

    JavaScript (JS) is a lightweight interpreted programming language with first-class functions.

  • web

    Some thing interesting about web. New door for the world.

  • server

    A server is a program made to process requests and deliver data to clients.

  • Machine learning

    Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.

  • Game

    Some thing interesting about game, make everyone happy.

Recommend Org

  • Facebook photo Facebook

    We are working to build community through open source technology. NB: members must have two-factor auth.

  • Microsoft photo Microsoft

    Open source projects and samples from Microsoft.

  • Google photo Google

    Google ❤️ Open Source for everyone.

  • D3 photo D3

    Data-Driven Documents codes.