赞
踩
一. 下载源码
GitHub - milvus-io/milvus-sdk-node: The Official Mivus node.js sdk(client)
二、初始化
进入根目录:
pnpm install
三、修改DataQuerty.ts 的数据库链接地址为milvus地址
四、ts-node DataQuery.tx
报错如下:
- Error: Cannot find module '@xenova/transformers'
- Require stack:
- - /data2/vector/milvus/milvus-sdk-node/node_modules/.pnpm/langchain@0.0.200/node_modules/langchain/dist/embeddings/hf_transformers.cjs
- - /data2/vector/milvus/milvus-sdk-node/node_modules/.pnpm/langchain@0.0.200/node_modules/langchain/embeddings/hf_transformers.cjs
- - /data2/vector/milvus/milvus-sdk-node/examples/milvus/embeddingTest.ts
- at Function.Module._resolveFilename (node:internal/modules/cjs/loader:1134:15)
- at Function.Module._resolveFilename.sharedData.moduleResolveFilenameHook.installedValue [as _resolveFilename] (/usr/local/lib/node_modules/ts-node/node_modules/@cspotcode/source-map-support/source-map-support.js:811:30)
- at Function.Module._load (node:internal/modules/cjs/loader:975:27)
- at Module.require (node:internal/modules/cjs/loader:1225:19)
- at require (node:internal/modules/helpers:177:18)
- at Object.<anonymous> (/data2/vector/milvus/milvus-sdk-node/node_modules/.pnpm/langchain@0.0.200/node_modules/langchain/dist/embeddings/hf_transformers.cjs:4:24)
- at Module._compile (node:internal/modules/cjs/loader:1356:14)
- at Module._extensions..js (node:internal/modules/cjs/loader:1414:10)
- at Object.require.extensions.<computed> [as .js] (/usr/local/lib/node_modules/ts-node/src/index.ts:1608:43)
- at Module.load (node:internal/modules/cjs/loader:1197:32) {
- code: 'MODULE_NOT_FOUND',
- requireStack: [
- '/data2/vector/milvus/milvus-sdk-node/node_modules/.pnpm/langchain@0.0.200/node_modules/langchain/dist/embeddings/hf_transformers.cjs',
- '/data2/vector/milvus/milvus-sdk-node/node_modules/.pnpm/langchain@0.0.200/node_modules/langchain/embeddings/hf_transformers.cjs',
- '/data2/vector/milvus/milvus-sdk-node/examples/milvus/embeddingTest.ts'
- ]
- }
1. 安装transfromer
pnpm i '@xenova/transformers' -D
- base) gw00241401@gw00241401-pc:/data2/vector/milvus/milvus-sdk-node$ pnpm i '@xenova/transformers' -D
- Packages: +45 -1
- +++++++++++++++++++++++++++++++++++++++++++++-
- Progress: resolved 463, reused 462, downloaded 0, added 45, done
-
- devDependencies:
- + @xenova/transformers 2.9.0
-
- WARN Issues with peer dependencies found
- .
- └─┬ typedoc 0.24.8
- └── ✕ unmet peer typescript@"4.6.x || 4.7.x || 4.8.x || 4.9.x || 5.0.x || 5.1.x": found 5.3.2
-
- Done in 8.4s
2.运行tsnode 报错
- (base) gw00241401@gw00241401-pc:/data2/vector/milvus/milvus-sdk-node$ ts-node ./examples/milvus/embeddingTest.ts
- /usr/local/lib/node_modules/ts-node/dist/index.js:851
- return old(m, filename);
- ^
- Error [ERR_REQUIRE_ESM]: require() of ES Module /data2/vector/milvus/milvus-sdk-node/node_modules/.pnpm/@xenova+transformers@2.9.0/node_modules/@xenova/transformers/src/transformers.js from /data2/vector/milvus/milvus-sdk-node/node_modules/.pnpm/langchain@0.0.200_@xenova+transformers@2.9.0/node_modules/langchain/dist/embeddings/hf_transformers.cjs not supported.
- Instead change the require of transformers.js in /data2/vector/milvus/milvus-sdk-node/node_modules/.pnpm/langchain@0.0.200_@xenova+transformers@2.9.0/node_modules/langchain/dist/embeddings/hf_transformers.cjs to a dynamic import() which is available in all CommonJS modules.
- at require.extensions.<computed> [as .js] (/usr/local/lib/node_modules/ts-node/dist/index.js:851:20)
- at Object.<anonymous> (/data2/vector/milvus/milvus-sdk-node/node_modules/.pnpm/langchain@0.0.200_@xenova+transformers@2.9.0/node_modules/langchain/dist/embeddings/hf_transformers.cjs:4:24)
- at require.extensions.<computed> [as .js] (/usr/local/lib/node_modules/ts-node/dist/index.js:851:20)
- at Object.<anonymous> (/data2/vector/milvus/milvus-sdk-node/node_modules/.pnpm/langchain@0.0.200_@xenova+transformers@2.9.0/node_modules/langchain/embeddings/hf_transformers.cjs:1:18)
- at require.extensions.<computed> [as .js] (/usr/local/lib/node_modules/ts-node/dist/index.js:851:20)
- at Object.<anonymous> (/data2/vector/milvus/milvus-sdk-node/examples/milvus/embeddingTest.ts:3:27)
- at m._compile (/usr/local/lib/node_modules/ts-node/dist/index.js:857:29)
- at require.extensions.<computed> [as .ts] (/usr/local/lib/node_modules/ts-node/dist/index.js:859:16)
- at phase4 (/usr/local/lib/node_modules/ts-node/dist/bin.js:466:20)
- at bootstrap (/usr/local/lib/node_modules/ts-node/dist/bin.js:54:12)
- at main (/usr/local/lib/node_modules/ts-node/dist/bin.js:33:12)
- at Object.<anonymous> (/usr/local/lib/node_modules/ts-node/dist/bin.js:579:5) {
- code: 'ERR_REQUIRE_ESM'
Copyright © 2003-2013 www.wpsshop.cn 版权所有,并保留所有权利。