diff --git a/.changeset/good-ants-fix.md b/.changeset/good-ants-fix.md new file mode 100644 index 0000000000..00a27804e9 --- /dev/null +++ b/.changeset/good-ants-fix.md @@ -0,0 +1,6 @@ +--- +"llamaindex": patch +"@llamaindex/env": patch +--- + +Allow Node 18 again (throw run-time error if not possible) to make Stackblitz work diff --git a/.github/workflows/test.yml b/.github/workflows/test.yml index bfdb7a0742..4e5162b206 100644 --- a/.github/workflows/test.yml +++ b/.github/workflows/test.yml @@ -23,7 +23,7 @@ jobs: strategy: fail-fast: false matrix: - node-version: [20.x, 22.x, 23.x] + node-version: [18.x, 20.x, 22.x, 23.x] name: E2E on Node.js ${{ matrix.node-version }} runs-on: ubuntu-latest steps: @@ -53,7 +53,7 @@ jobs: strategy: fail-fast: false matrix: - node-version: [20.x, 22.x, 23.x] + node-version: [18.x, 20.x, 22.x, 23.x] name: Test on Node.js ${{ matrix.node-version }} runs-on: ubuntu-latest steps: diff --git a/packages/env/src/internal/multi-model/node.ts b/packages/env/src/internal/multi-model/node.ts index b653cf6161..13826c67b7 100644 --- a/packages/env/src/internal/multi-model/node.ts +++ b/packages/env/src/internal/multi-model/node.ts @@ -7,6 +7,13 @@ export { } from "./shared.js"; export async function loadTransformers(onLoad: OnLoad) { + const nodeVersions = process.versions.node.split("."); + if (nodeVersions[0] && parseInt(nodeVersions[0], 10) < 20) { + throw new Error( + "@huggingface/transformers is not supported on Node.js versions below 20", + ); + } + if (getTransformers() === null) { setTransformers(await import("@huggingface/transformers")); } else { diff --git a/packages/llamaindex/package.json b/packages/llamaindex/package.json index f221acfa94..21ba3e5951 100644 --- a/packages/llamaindex/package.json +++ b/packages/llamaindex/package.json @@ -86,7 +86,6 @@ } }, "devDependencies": { - "@huggingface/transformers": "^3.0.2", "@swc/cli": "^0.5.0", "@swc/core": "^1.9.2", "@vercel/postgres": "^0.10.0", @@ -98,7 +97,7 @@ "typescript": "^5.6.3" }, "engines": { - "node": ">=20.0.0" + "node": ">=18.0.0" }, "types": "./dist/type/index.d.ts", "main": "./dist/cjs/index.js",