Business
Jobs
  • About Us
  • Solutions
    • Job Postings
      Post your job and receive qualified candidates in 48h.
    • Candidate Assessments
      500+ technical and psychological tests, plus anti-fraud.
    • Headhunting
      Tailor-made executive search from start to finish.
    • Payroll + EOR
      Payroll dispersal and EOR across 15+ LATAM countries.
  • Pricing
  • Jobs

0

207
Views
Function not running properly in Nodejs

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)

about 4 years ago · Juan Pablo Isaza
1 answers
Answer question

0

The ./ references the same directory/folder that the file is. You can think on it as the current directory/folder.

about 4 years ago · Juan Pablo Isaza Report
Answer question
Find remote jobs

Discover the new way to find a job!

Top jobs
Top job categories
Business
Post vacancy Pricing Sales
Legal
Terms and conditions Privacy policy
© 2026 PeakU Inc. All Rights Reserved.
Andres GPT
Show me some job opportunities
There's an error!