Skip to content

Ollama Not Import Module on Node JS #212

@nandarbin

Description

@nandarbin

import ollama from 'ollama';

console.log("Using Ollama version:", ollama);
// const ollama = await import("ollama");
export const c_chat = async (req, res) => {
try {
if(!req.body){
return res.status(305).send({
status : "Data Masih Kosong"
});
}
const response = await ollama.chat({
model : req.body.model,
messages : req.body.pesan
});
res.status(200).send({
response : response.message
});
}
catch (e) {
return res.status(305).send({
status: e.message
});
}
}

### my code, but error in the bellow

Debugger attached.
Waiting for the debugger to disconnect...
file:///E:/express/node/node_modules/ollama/dist/browser.mjs:57
if (response.headers.get("content-type")?.includes("application/json")) {
^

SyntaxError: Unexpected token '.'
at Loader.moduleStrategy (internal/modules/esm/translators.js:140:18)
[nodemon] app crashed - waiting for file changes before starting...

my using node 18.17.1

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