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

node_modules/ollama/dist/index.mjs (2:13): "promises" is not exported by "node_modules/node-stdlib-browser/esm/mock/empty.js", imported by "node_modules/ollama/dist/index.mjs". #141

Open
czwlkjgzs opened this issue Sep 7, 2024 · 1 comment

Comments

@czwlkjgzs
Copy link

x Build failed in 9.38s
error during build:
node_modules/ollama/dist/index.mjs (2:13): "promises" is not exported by "node_modules/node-stdlib-browser/esm/mock/empty.js", imported by "node_modules/ollama/dist/index.mjs".
file: D:/myCodes/projectCodes/czwl-ollama-webui/node_modules/ollama/dist/index.mjs:2:13

1: import { O as Ollama$1, h as head, p as post } from './shared/ollama.5360ad67.mjs';
2: import fs, { promises, createReadStream } from 'fs';
                ^
3: import { resolve, join, dirname } from 'path';
4: import { createHash } from 'crypto';

    at getRollupError (file:///D:/myCodes/projectCodes/czwl-ollama-webui/node_modules/rollup/dist/es/shared/parseAst.js:392:41)
    at error (file:///D:/myCodes/projectCodes/czwl-ollama-webui/node_modules/rollup/dist/es/shared/parseAst.js:388:42)
    at Module.error (file:///D:/myCodes/projectCodes/czwl-ollama-webui/node_modules/rollup/dist/es/shared/node-entry.js:13967:16)
    at Module.traceVariable (file:///D:/myCodes/projectCodes/czwl-ollama-webui/node_modules/rollup/dist/es/shared/node-entry.js:14414:29)
    at ModuleScope.findVariable (file:///D:/myCodes/projectCodes/czwl-ollama-webui/node_modules/rollup/dist/es/shared/node-entry.js:12121:39)
    at ChildScope.findVariable (file:///D:/myCodes/projectCodes/czwl-ollama-webui/node_modules/rollup/dist/es/shared/node-entry.js:7467:38)
    at ClassBodyScope.findVariable (file:///D:/myCodes/projectCodes/czwl-ollama-webui/node_modules/rollup/dist/es/shared/node-entry.js:7467:38)
    at ChildScope.findVariable (file:///D:/myCodes/projectCodes/czwl-ollama-webui/node_modules/rollup/dist/es/shared/node-entry.js:7467:38)
    at ChildScope.findVariable (file:///D:/myCodes/projectCodes/czwl-ollama-webui/node_modules/rollup/dist/es/shared/node-entry.js:7467:38)
    at FunctionScope.findVariable (file:///D:/myCodes/projectCodes/czwl-ollama-webui/node_modules/rollup/dist/es/shared/node-entry.js:7467:38)

I've already use import ollama from ollama/browser.
But the error occured when I try vite build.

this is my vite.config.js

import {fileURLToPath, URL} from 'node:url'
import AutoImport from 'unplugin-auto-import/vite'
import Components from 'unplugin-vue-components/vite'
import {ElementPlusResolver} from 'unplugin-vue-components/resolvers'
import {defineConfig} from 'vite'
import vue from '@vitejs/plugin-vue'
import {nodePolyfills} from "vite-plugin-node-polyfills"


// https://vitejs.dev/config/
export default defineConfig({
    plugins: [
        [vue()],
        AutoImport({
            imports: ['vue', 'vue-router'],
            // dts: 'src/auto-import.d.ts',
            dts: 'auto-import.d.ts',
            resolvers: [ElementPlusResolver()],
        }),
        Components({
            resolvers: [ElementPlusResolver()],
        }),
        nodePolyfills({protocolImports: true}),
    ],
    resolve: {
        alias: {
            '@': fileURLToPath(new URL('./src', import.meta.url))
        },
    }
})
@czwlkjgzs
Copy link
Author

I've solved this problem.
My vite version is 5.x, So I have to use --force parameter
npm install vite-plugin-node-stdlib-browser --force

if the suffix of the vite config file is .ts, you need to change .ts to .js.
Then configure as follows.

import nodeStdlibBrowser from 'vite-plugin-node-stdlib-browser';

export default defineConfig({
    plugins: [
       ...
        nodePolyfills({protocolImports: true}),
        nodeStdlibBrowser(),
       ...
    ],
})

There is still a problem here.

When I try vite build. Everything is ok.
But when I try vite. I have to comment out nodePolyfills({protocolImports: true}),

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

1 participant