Skip to content

Ollama 0.5.7 introduce a BREAKING CHANAGE for browser usage #132

@arvinxx

Description

@arvinxx

We use ollama-js in browser and edge runtime. But 0.5.7 seems intro the node into these cases, which cause the vercel build error:

image

here is the error stack:

node:fs
Module build failed: UnhandledSchemeError: Reading from "node:fs" is not handled by plugins (Unhandled scheme).
Webpack supports "data:" and "file:" URIs by default.
You may need an additional plugin to handle "node:" URIs.
    at /vercel/path0/node_modules/next/dist/compiled/webpack/bundle5.js:28:401757
    at Hook.eval [as callAsync] (eval at create (/vercel/path0/node_modules/next/dist/compiled/webpack/bundle5.js:13:28858), <anonymous>:6:1)
    at Object.processResource (/vercel/path0/node_modules/next/dist/compiled/webpack/bundle5.js:28:401682)
    at processResource (/vercel/path0/node_modules/next/dist/compiled/loader-runner/LoaderRunner.js:1:5308)
    at iteratePitchingLoaders (/vercel/path0/node_modules/next/dist/compiled/loader-runner/LoaderRunner.js:1:4667)
    at runLoaders (/vercel/path0/node_modules/next/dist/compiled/loader-runner/LoaderRunner.js:1:8590)
    at NormalModule._doBuild (/vercel/path0/node_modules/next/dist/compiled/webpack/bundle5.js:28:401544)
    at NormalModule.build (/vercel/path0/node_modules/next/dist/compiled/webpack/bundle5.js:28:403572)
    at /vercel/path0/node_modules/next/dist/compiled/webpack/bundle5.js:28:82055
    at NormalModule.needBuild (/vercel/path0/node_modules/next/dist/compiled/webpack/bundle5.js:28:407670)
Import trace for requested module:
node:fs
./node_modules/fetch-blob/from.js
./node_modules/node-fetch/src/index.js
./node_modules/ollama/dist/shared/ollama.7d273fc8.mjs
./node_modules/ollama/dist/browser.mjs
./src/libs/agent-runtime/ollama/index.ts
./src/libs/agent-runtime/index.ts
./src/app/api/chat/models/[provider]/route.ts

here is the reproduction repo and branch: https://github.com/lobehub/lobe-chat/tree/reproduction/ollama-0.5.7

pnpm i

pnpm run build

I think this issue is introduced by #125 , I suggest to revert this change.

Metadata

Metadata

Assignees

No one assigned

    Labels

    No labels
    No labels

    Type

    No type

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions