Open xuquankun opened 1 week ago
To resolve the npm error code EBADPLATFORM, follow these steps:
package.json
to conditionally install @lancedb/vectordb-win32-x64-msvc
only on Windows."optionalDependencies": {
"@lancedb/vectordb-win32-x64-msvc": "^0.5.0"
}
@lancedb/vectordb-win32-x64-msvc
is conditionally executed based on the platform. Update Lance.ts
to handle this.import * as lancedb from "vectordb";
import { errorToString } from "../Generic/error";
import { EnhancedEmbeddingFunction } from "./Embeddings";
import CreateDatabaseSchema, { isStringifiedSchemaEqual } from "./Schema";
const GetOrCreateLanceTable = async (
db: lancedb.Connection,
embedFunc: EnhancedEmbeddingFunction<string>,
userDirectory: string
): Promise<lancedb.Table<string>> => {
try {
const allTableNames = await db.tableNames();
const intendedSchema = CreateDatabaseSchema(embedFunc.contextLength);
const tableName = generateTableName(embedFunc.name, userDirectory);
if (allTableNames.includes(tableName)) {
const table = await db.openTable(tableName, embedFunc);
const schema = await table.schema;
if (!isStringifiedSchemaEqual(schema, intendedSchema)) {
await db.dropTable(tableName);
const recreatedTable = await db.createTable({
name: tableName,
schema: intendedSchema,
embeddingFunction: embedFunc,
});
return recreatedTable;
}
return table;
}
const newTable = await db.createTable({
name: tableName,
schema: intendedSchema,
embeddingFunction: embedFunc,
});
return newTable;
} catch (error) {
const errorMessage = `Error in GetOrCreateLanceTable: ${errorToString(
error
)}`;
console.error(errorMessage);
throw new Error(errorMessage);
}
};
export const generateTableName = (
embeddingFuncName: string,
userDirectory: string
): string => {
const sanitizeForFileSystem = (str: string) => {
return str.replace(/[<>:"/\\|?*]/g, "_");
};
const directoryPathAlias = sanitizeForFileSystem(userDirectory);
const sanitizedEmbeddingFuncName = sanitizeForFileSystem(embeddingFuncName);
return `ragnote_table_${sanitizedEmbeddingFuncName}_${directoryPathAlias}`;
};
export default GetOrCreateLanceTable;
scripts/downloadOllama.js
handles platform-specific binaries correctly.const platform = os.platform();
if (process.argv[2] === "all") {
Object.keys(binariesInfo).forEach(downloadIfMissing);
} else {
downloadIfMissing(platform);
}
These steps should help resolve the platform-specific dependency issue.
/package.json /scripts/downloadOllama.js /electron/main/database/Lance.ts
Hello, I encountered such an error: $ npm install npm error code EBADPLATFORM npm error notsup Unsupported platform for @lancedb/vectordb-win32-x64-msvc@0.5.0: wanted {"os":"win32","cpu":"x64"} (current: {"os":"linux","cpu":"x64"}) npm error notsup Valid os: win32 npm error notsup Actual os: linux npm error notsup Valid cpu: x64 npm error notsup Actual cpu: x64 npm error A complete log of this run can be found in: /home/xqk/.npm/_logs/2024-06-26T02_51_09_436Z-debug-0.log
When I run the compiled exe file, and I get this error again, I see that you asked the same question under the vectordb project, how did you solve it?
Error: vectordb: failed to load native library. You may need to run
npm install @lancedb/vectordb-win32-x64-msvc
.If that does not work, please file a bug report at https://github.com/lancedb/lancedb/issues
Source error: Error: The specified module could not be found. \?\C:\Users\sam\Desktop\vite-ragnote\node_modules\@lancedb\vectordb-win32-x64-msvc\index.node at Object. (C:\Users\sam\Desktop\vite-ragnote\node_modules\vectordb\native.js:26:11)
at Module._compile (node:internal/modules/cjs/loader:1271:14)
at Object..js (node:internal/modules/cjs/loader:1326:10)
at Module.load (node:internal/modules/cjs/loader:1126:32)
at node:internal/modules/cjs/loader:967:12
at Function._load (node:electron/js2c/asar_bundle:2:13327)
at Module.require (node:internal/modules/cjs/loader:1150:19)
at require (node:internal/modules/cjs/helpers:110:18)
at Object. (C:\Users\sam\Desktop\vite-ragnote\node_modules\vectordb\dist\query.js:28:25)
at Module._compile (node:internal/modules/cjs/loader:1271:14)