Trying to run this function but there's no output
const fs = require("fs");
const { createCanvas, loadImage } = require("canvas");
const console = require("console");
const canvas = createCanvas(1000, 1000);
const ctx = canvas.getContext("2d");
const drawLayer = async () => {
const image = await loadImage("./batmanpfp.png");
ctx.drawImage(image, 0, 0, 1000, 1000);
console.log("this ran.");5
};
drawLayer( );
OUTPUT(tried running it many times, no output)
PS C:\Users\USER\Desktop\NFT2> node index.js
PS C:\Users\USER\Desktop\NFT2> node index.js
PS C:\Users\USER\Desktop\NFT2> node index.js
PS C:\Users\USER\Desktop\NFT2> node index.js
PS C:\Users\USER\Desktop\NFT2> node index.js
PS C:\Users\USER\Desktop\NFT2> node index.js
PS C:\Users\USER\Desktop\NFT2> node index.js
I am not a coder, learning from here: https://www.youtube.com/watch?v=3c2EFpCr_vY&list=PLvfQp12V0hS3AVImYdMNfkdvRtZEe7xqY
Possible Issue: Am I making a mistake in const image = await loadImage("./batmanpfp.png"); as I do not know the significance of "./" but the file I am calling is in my root (root folder is called NFT)
The ./ references the same directory/folder that the file is. You can think on it as the current directory/folder.