Require Vs Import, trying to "import" another script via the require method.

So I was following the discordjs.guide site on setting up the bot and they used require for everything,
const fs = require('node:fs');
const path = require('node:path');
const { Client, Collection, GatewayIntentBits } = require('discord.js');
const { token } = require('./config.json');

Example ^

So now in one of my slash-commands I'm trying to get one of my scripts, which normally I'd do, for example:
import { getHydraAccess } from "./apiAccess/hydra.js";

However I need to choose require instead of import, and I followed the code along, so it's a bit too much for me to try and make all the rest of the code and the way it's written utilize the import feature versus require.

So I followed the same format as the others and wrote:
const { getHydraAccess } = require('./apiAccess/hydra.js');


However now I'm getting the error: Error: Cannot find module './apiAccess/hydra.js'

No matter what I do, it can't find it properly and I'm not sure what to change as I'm used to the import/export method, and attempting to figure out the require method for this.
Was this page helpful?