---
title: "Instalación"
description: "Instala @nodecfdi/xml-schema-validator en proyectos ESM de Node.js y realiza tu primera validación XSD local."
canonical_url: "https://nodecfdi.com/packages/xml-schema-validator/getting-started/installation"
---

> Index of every page on this site: [llms.txt](https://nodecfdi.com/llms.txt)

Instala `@nodecfdi/xml-schema-validator` usando tu gestor de paquetes preferido:

<code-group>

```bash [pnpm]
pnpm add @nodecfdi/xml-schema-validator
```

```bash [npm]
npm install @nodecfdi/xml-schema-validator
```

```bash [yarn]
yarn add @nodecfdi/xml-schema-validator
```

```bash [bun]
bun add @nodecfdi/xml-schema-validator
```

</code-group>

<note>

Este paquete se distribuye exclusivamente como **ESM** (`"type": "module"`). Tanto `@nodecfdi/cfdi-core` como `libxml2-wasm` se instalan automáticamente como dependencias directas y no requieren configuración manual de DOM ni compilación nativa.

</note>

## Verificación rápida

Una vez instalado, crea un script para validar un archivo XML contra un esquema XSD almacenado localmente:

```ts [validate.ts]
import { readFileSync } from 'node:fs';
import { Schemas, SchemaValidator } from '@nodecfdi/xml-schema-validator';

const xmlContent = readFileSync('./factura.xml', 'utf8');
const validator = SchemaValidator.createFromString(xmlContent);

const schemas = new Schemas();
schemas.create('http://www.sat.gob.mx/cfd/4', './xsd/cfdv40.xsd');

const isValid = validator.validate(schemas);

if (isValid) {
  console.info('El XML es válido.');
} else {
  console.error('XML inválido:', validator.getLastError());
}
```

## Próximos pasos

Explora las opciones de [validación básica](https://nodecfdi.com/packages/xml-schema-validator/usage/basic-validation) o aprende cómo resolver [esquemas remotos](https://nodecfdi.com/packages/xml-schema-validator/remote-schemas/xml-resource-retriever).

## Sitemap

See the full [sitemap](https://nodecfdi.com/sitemap.md) for all pages.
