“Compruebe de nodo si existe el archivo” Código de respuesta

Compruebe de nodo si existe el archivo

const fs = require("fs"); // Or `import fs from "fs";` with ESM
if (fs.existsSync(path)) {
    // Do something
}
Witty Worm

nodo si existe el archivo

const fs = require("fs"); // Or `import fs from "fs";` with ESM
if (fs.existsSync(path)) {
    // Do something
}
gaz_edge

Existe el archivo NodeJS

const fs = require('fs')
// We will convert sync function into a promise function
// so when is ready will provide the result without blocking.
const exists = async (path) => {
	return await new Promise((resolve) => {
		resolve(fs.existsSync(path));
	});
};
// If you have a file name samples on same root it will result true.
exists('./samples.txt').then(res => console.log(res))
console.log(`I'm not blocked as I'll show up on first`)
God Of Coding

Respuestas similares a “Compruebe de nodo si existe el archivo”

Preguntas similares a “Compruebe de nodo si existe el archivo”

Más respuestas relacionadas con “Compruebe de nodo si existe el archivo” en JavaScript

Explore las respuestas de código populares por idioma

Explorar otros lenguajes de código