I have a Meteor installation from scratch on a M2 mac, I only installed langchain for use with ollama and I can’t get it to work, below are the steps to reproduce and log in full.
meteor create project
meteor npm i @langchain/ollama @langchain/core
my server/main.js
file I only added the example from the langchain ollama documentation
import { Meteor } from 'meteor/meteor';
import { ChatOllama } from '@langchain/ollama';
Meteor.startup(async () => {
const llm = new ChatOllama({
model: "llama3.1",
temperature: 0,
maxRetries: 2,
// other params...
});
const aiMsg = await llm.invoke([
[
"system",
"You are a helpful assistant that translates English to French. Translate the user sentence.",
],
["human", "I love programming."],
]);
console.log(aiMsg);
});
below log when running meteor
:
[[[[[ ~/workspace/project ]]]]]
=> Started proxy.
=> Started HMR server.
Unable to resolve some modules:
"ollama/browser" in
/Users/robersonfaria/workspace/project/node_modules/@langchain/ollama/dist/chat_models.js
(os.osx.arm64)
If you notice problems related to these missing modules, consider running:
meteor npm install --save ollama
=> Started MongoDB.
W20241010-21:55:18.119(-3)? (STDERR) packages/core-runtime.js:189
W20241010-21:55:18.128(-3)? (STDERR) throw error;
W20241010-21:55:18.128(-3)? (STDERR) ^
W20241010-21:55:18.128(-3)? (STDERR)
W20241010-21:55:18.128(-3)? (STDERR) Error: Cannot find module 'ollama/browser'
W20241010-21:55:18.128(-3)? (STDERR) at makeMissingError (packages/modules-runtime.js:221:12)
W20241010-21:55:18.128(-3)? (STDERR) at Module.require (packages/modules-runtime.js:240:17)
W20241010-21:55:18.128(-3)? (STDERR) at Module.mod.require (/Users/robersonfaria/.meteor/packages/modules/.0.20.1.z1mc19.sfl2m++os+web.browser+web.browser.legacy+web.cordova/npm/node_modules/@meteorjs/reify/lib/runtime/index.js:30:33)
W20241010-21:55:18.128(-3)? (STDERR) at Module.moduleLink [as link] (/Users/robersonfaria/.meteor/packages/modules/.0.20.1.z1mc19.sfl2m++os+web.browser+web.browser.legacy+web.cordova/npm/node_modules/@meteorjs/reify/lib/runtime/index.js:104:22)
W20241010-21:55:18.128(-3)? (STDERR) at module (packages/modules.js:257:261)
W20241010-21:55:18.128(-3)? (STDERR) at fileEvaluate (packages/modules-runtime.js:335:7)
W20241010-21:55:18.128(-3)? (STDERR) at Module.require (packages/modules-runtime.js:237:14)
W20241010-21:55:18.128(-3)? (STDERR) at Module.mod.require (/Users/robersonfaria/.meteor/packages/modules/.0.20.1.z1mc19.sfl2m++os+web.browser+web.browser.legacy+web.cordova/npm/node_modules/@meteorjs/reify/lib/runtime/index.js:30:33)
W20241010-21:55:18.128(-3)? (STDERR) at Module.moduleLink [as link] (/Users/robersonfaria/.meteor/packages/modules/.0.20.1.z1mc19.sfl2m++os+web.browser+web.browser.legacy+web.cordova/npm/node_modules/@meteorjs/reify/lib/runtime/index.js:104:22)
W20241010-21:55:18.128(-3)? (STDERR) at module (packages/modules.js:242:8)
W20241010-21:55:18.128(-3)? (STDERR) at fileEvaluate (packages/modules-runtime.js:335:7)
W20241010-21:55:18.128(-3)? (STDERR) at Module.require (packages/modules-runtime.js:237:14)
W20241010-21:55:18.128(-3)? (STDERR) at Module.mod.require (/Users/robersonfaria/.meteor/packages/modules/.0.20.1.z1mc19.sfl2m++os+web.browser+web.browser.legacy+web.cordova/npm/node_modules/@meteorjs/reify/lib/runtime/index.js:30:33)
W20241010-21:55:18.128(-3)? (STDERR) at Module.moduleLink [as link] (/Users/robersonfaria/.meteor/packages/modules/.0.20.1.z1mc19.sfl2m++os+web.browser+web.browser.legacy+web.cordova/npm/node_modules/@meteorjs/reify/lib/runtime/index.js:104:22)
W20241010-21:55:18.129(-3)? (STDERR) at module (packages/modules.js:231:8)
W20241010-21:55:18.129(-3)? (STDERR) at fileEvaluate (packages/modules-runtime.js:335:7)
W20241010-21:55:18.129(-3)? (STDERR)
W20241010-21:55:18.129(-3)? (STDERR) Node.js v20.17.0
=> Exited with code: 1
=> Your application is crashing. Waiting for file change.
I’ve already tried following the ollama installation suggestion, I also tried installing ollama/browser, nothing works
Just for testing, I created a test project with a simple npm init
and installed the same packages and ran the same code, and everything worked normally, so I believe it is a bug with meteor.
I would like to use meteor in this project, if you know how to help me, I would appreciate it.