Can’t find variable: require at global code@

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");