Empresas
Empleos
  • Sobre nosotros
  • Soluciones
    • Publicación de vacantes
      Publica tu vacante y recibe candidatos calificados en 48h.
    • Evaluación de candidatos
      500+ pruebas técnicas y psicológicas, más anti-fraude.
    • Headhunting
      Búsqueda ejecutiva a la medida de principio a fin.
    • Nómina + EOR
      Dispersión de nómina y EOR en más de 15 países de LATAM.
  • Precios
  • Empleos

0

211
Vistas
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 Respuestas
Responde la pregunta

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 Denunciar
Responde la pregunta
Encuentra empleos remotos

¡Descubre la nueva forma de encontrar empleo!

Top de empleos
Top categorías de empleo
Empresas
Publicar vacante Precios Comercial
Legal
Términos y condiciones Política de privacidad
© 2026 PeakU Inc. All Rights Reserved.
Andres GPT
Recomiéndame algunas ofertas
Necesito ayuda