Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Ollama: running Vite in production mode fails #4516

Open
ejgutierrez74 opened this issue May 18, 2024 · 7 comments
Open

Ollama: running Vite in production mode fails #4516

ejgutierrez74 opened this issue May 18, 2024 · 7 comments
Assignees
Labels
bug Something isn't working

Comments

@ejgutierrez74
Copy link

What is the issue?

Im developing web app for educational purpose. I use React + Vite. Till now in development mode im not facing great problems.... But now i have tried to run in production mode and got the error below: h

vite v5.2.10 building for production...
[plugin:vite:resolve] [plugin vite:resolve] Module "fs" has been externalized for browser compatibility, imported by "/home/eduardo/Descargas/workshop-react/node_modules/ollama/dist/index.mjs". See https://vitejs.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/Descargas/workshop-react/node_modules/ollama/dist/index.mjs". See https://vitejs.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/Descargas/workshop-react/node_modules/ollama/dist/index.mjs". See https://vitejs.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/Descargas/workshop-react/node_modules/ollama/dist/index.mjs". See https://vitejs.dev/guide/troubleshooting.html#module-externalized-for-browser-compatibility for more details.
✓ 1052 modules transformed.
x Build failed in 1.49s
error during build:
RollupError: node_modules/ollama/dist/index.mjs (2:13): "promises" is not exported by "__vite-browser-external", imported by "node_modules/ollama/dist/index.mjs".
file: /home/eduardo/Descargas/workshop-react/node_modules/ollama/dist/index.mjs:2:13
1: import { O as Ollama$1, h as head, p as post } from './shared/ollama.14e58652.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/Descargas/workshop-react/node_modules/vite/node_modules/rollup/dist/es/shared/parseAst.js:394:41)
    at error (file:///home/eduardo/Descargas/workshop-react/node_modules/vite/node_modules/rollup/dist/es/shared/parseAst.js:390:42)
    at Module.error (file:///home/eduardo/Descargas/workshop-react/node_modules/vite/node_modules/rollup/dist/es/shared/node-entry.js:13860:16)
    at Module.traceVariable (file:///home/eduardo/Descargas/workshop-react/node_modules/vite/node_modules/rollup/dist/es/shared/node-entry.js:14308:29)
    at ModuleScope.findVariable (file:///home/eduardo/Descargas/workshop-react/node_modules/vite/node_modules/rollup/dist/es/shared/node-entry.js:11989:39)
    at ChildScope.findVariable (file:///home/eduardo/Descargas/workshop-react/node_modules/vite/node_modules/rollup/dist/es/shared/node-entry.js:7432:38)
    at ClassBodyScope.findVariable (file:///home/eduardo/Descargas/workshop-react/node_modules/vite/node_modules/rollup/dist/es/shared/node-entry.js:7432:38)
    at ChildScope.findVariable (file:///home/eduardo/Descargas/workshop-react/node_modules/vite/node_modules/rollup/dist/es/shared/node-entry.js:7432:38)
    at ChildScope.findVariable (file:///home/eduardo/Descargas/workshop-react/node_modules/vite/node_modules/rollup/dist/es/shared/node-entry.js:7432:38)
    at FunctionScope.findVariable (file:///home/eduardo/Descargas/workshop-react/node_modules/vite/node_modules/rollup/dist/es/shared/node-entry.js:7432:38)

As for Vite is a problem that should be fixed by ollama ( the library) :https://vitejs.dev/guide/troubleshooting.html#module-externalized-for-browser-compatibility

Just if not clear: npm run dev works, but when i tried npm run build....i got the error above.

Hope this could be fixed soon.

Thanks

OS

No response

GPU

No response

CPU

No response

Ollama version

0.1.37

@ejgutierrez74 ejgutierrez74 added the bug Something isn't working label May 18, 2024
@thinkverse
Copy link

This seems like an issue that should be created on https://github.com/ollama/ollama-js instead.

@pdevine
Copy link
Contributor

pdevine commented May 18, 2024

cc @BruceMacD

@ejgutierrez74
Copy link
Author

Then should i post in ollama-js ?? But i only installed ollama ( npm install ollama) in my project. Not ollamajs....
Hope this could be fixed soon...
Thanks

@thinkverse
Copy link

thinkverse commented May 19, 2024

Then should i post in ollama-js ?? But i only installed ollama ( npm install ollama) in my project. Not ollamajs....

ollama/ollama-js is the repository for the npm package. This repository ollama/ollama, is for the actual Ollama service you install on your computer or server, not the npm package. It's for the service the npm package interacts with.

And you don't have to post it again there, the Ollama team can transfer the issue over manually. 👍

@imareo
Copy link

imareo commented May 26, 2024

import fs, { promises, createReadStream } from 'fs';

you can't use 'fs/promises' inside browser.

maybe help this: vitejs/vite#8799 (reply in thread)
in my case I rewrite code using api.

@ejgutierrez74
Copy link
Author

ejgutierrez74 commented May 26, 2024

The link you provided is broken....

But the thing is that in dev mode it hasnt any problems....

@imareo
Copy link

imareo commented May 26, 2024

vite build dist for browser, for run dev mode used nodejs

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
bug Something isn't working
Projects
None yet
Development

No branches or pull requests

5 participants