You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
Build failed with vite build "promises" is not exported by "__vite-browser-external", imported by "node_modules/.pnpm/[email protected]/node_modules/ollama/dist/index.mjs".
#189
Open
ejgutierrez74 opened this issue
Jan 4, 2025
· 3 comments
`vite v6.0.6 building for production...
[plugin:vite:resolve] [plugin vite:resolve] Module "fs" has been externalized for browser compatibility, imported by "/home/eduardo/WebstormProjects/MeuPacman/node_modules/.pnpm/[email protected]/node_modules/ollama/dist/index.mjs". See https://vite.dev/guide/troubleshooting.html#module-externalized-for-browser-compatibility for more details.
[plugin:vite:resolve] [plugin vite:resolve] Module "path" has been externalized for browser compatibility, imported by "/home/eduardo/WebstormProjects/MeuPacman/node_modules/.pnpm/[email protected]/node_modules/ollama/dist/index.mjs". See https://vite.dev/guide/troubleshooting.html#module-externalized-for-browser-compatibility for more details.
[plugin:vite:resolve] [plugin vite:resolve] Module "crypto" has been externalized for browser compatibility, imported by "/home/eduardo/WebstormProjects/MeuPacman/node_modules/.pnpm/[email protected]/node_modules/ollama/dist/index.mjs". See https://vite.dev/guide/troubleshooting.html#module-externalized-for-browser-compatibility for more details.
[plugin:vite:resolve] [plugin vite:resolve] Module "os" has been externalized for browser compatibility, imported by "/home/eduardo/WebstormProjects/MeuPacman/node_modules/.pnpm/[email protected]/node_modules/ollama/dist/index.mjs". See https://vite.dev/guide/troubleshooting.html#module-externalized-for-browser-compatibility for more details.
✓ 79 modules transformed.
x Build failed in 654ms
error during build:
node_modules/.pnpm/[email protected]/node_modules/ollama/dist/index.mjs (2:13): "promises" is not exported by "__vite-browser-external", imported by "node_modules/.pnpm/[email protected]/node_modules/ollama/dist/index.mjs".
file: /home/eduardo/WebstormProjects/MeuPacman/node_modules/.pnpm/[email protected]/node_modules/ollama/dist/index.mjs:2:13
1: import { O as Ollama$1, h as head, p as post } from './shared/ollama.cddbc85b.mjs';
2: import fs, { promises, createReadStream } from 'fs';
^
3: import { resolve, join, dirname } from 'path';
4: import { createHash } from 'crypto';
at getRollupError (file:///home/eduardo/WebstormProjects/MeuPacman/node_modules/.pnpm/[email protected]/node_modules/rollup/dist/es/shared/parseAst.js:396:41)
at error (file:///home/eduardo/WebstormProjects/MeuPacman/node_modules/.pnpm/[email protected]/node_modules/rollup/dist/es/shared/parseAst.js:392:42)
at Module.error (file:///home/eduardo/WebstormProjects/MeuPacman/node_modules/.pnpm/[email protected]/node_modules/rollup/dist/es/shared/node-entry.js:15655:16)
at Module.traceVariable (file:///home/eduardo/WebstormProjects/MeuPacman/node_modules/.pnpm/[email protected]/node_modules/rollup/dist/es/shared/node-entry.js:16104:29)
at ModuleScope.findVariable (file:///home/eduardo/WebstormProjects/MeuPacman/node_modules/.pnpm/[email protected]/node_modules/rollup/dist/es/shared/node-entry.js:13887:39)
at ChildScope.findVariable (file:///home/eduardo/WebstormProjects/MeuPacman/node_modules/.pnpm/[email protected]/node_modules/rollup/dist/es/shared/node-entry.js:5306:38)
at ClassBodyScope.findVariable (file:///home/eduardo/WebstormProjects/MeuPacman/node_modules/.pnpm/[email protected]/node_modules/rollup/dist/es/shared/node-entry.js:5306:38)
at ChildScope.findVariable (file:///home/eduardo/WebstormProjects/MeuPacman/node_modules/.pnpm/[email protected]/node_modules/rollup/dist/es/shared/node-entry.js:5306:38)
at ChildScope.findVariable (file:///home/eduardo/WebstormProjects/MeuPacman/node_modules/.pnpm/[email protected]/node_modules/rollup/dist/es/shared/node-entry.js:5306:38)
at FunctionScope.findVariable (file:///home/eduardo/WebstormProjects/MeuPacman/node_modules/.pnpm/[email protected]/node_modules/rollup/dist/es/shared/node-entry.js:5306:38)
ELIFECYCLE Command failed with exit code 1.
`
The text was updated successfully, but these errors were encountered:
Vite is likely building a static site that may not be ran with node, so you don't have access to libraries that you require node for when trying to run with the built files.
Instead of importing from ollama, import from ollama/browser and it should work.
As for differences, the code is in this repo, you can see for yourself! 😅 tldr; the non browser import uses nodejs dependencies and is usable via running an app with nodejs. The browser import uses dependences and code compatible with a browser environment. Your Vite setup is likely packaging up a static build, so it can be ran with nginx, caddy, go, rust... whatever you want to serve HTML. So if you import modules that are from node, they won't work.
I found this error: in vite in dev works fine, but when i make a run build to run a vite build i got:
Seems its an error in ollama-js side as written in Vite documentation: https://vite.dev/guide/troubleshooting.html#module-externalized-for-browser-compatibility
The text was updated successfully, but these errors were encountered: