Reputation: 147
I'm new to JavaScript and was trying to import the Google Gemini library to use its AI. However, I'm facing an issue when I use the "require" keyword:
ERROR: Can't find variable: require at global code@
Here is the code that throws this error:
const {
GoogleGenerativeAI,
// HarmCategory,
// HarmBlockThreshold,
} = require("@google/generative-ai");
Upvotes: 2
Views: 110
Reputation: 599
Try removing
const {
GoogleGenerativeAI,
HarmCategory,
HarmBlockThreshold,
} = require("@google/generative-ai");
And replace with
import { GoogleGenerativeAI } from "@google/generative-ai";
Upvotes: -1