# node-yaml

> A wrapper for js-yaml parser

Latest version **4.0.1** (published 2019-07-09) · MIT license · 0 weekly downloads

## Install

```sh
npm install node-yaml
pnpm add node-yaml
yarn add node-yaml
bun add node-yaml
```

## Health

**Score 15/100 (F)** — status: abandoned.

Positive: no vulnerabilities.

Warnings: low downloads; no types; no esm support.

Negative: abandoned; low maintenance score.

## Facts

| | |
|---|---|
| Version | 4.0.1 |
| Published | 2019-07-09 |
| First published | 2015-11-29 |
| Weekly downloads | 0 |
| License | MIT |
| TypeScript types | none |
| Module format | CommonJS |
| Dependencies | 3 |
| Unpacked size | 10.2 KB |
| Known vulnerabilities | 0 |
| Install scripts | no |
| GitHub stars | 23 |
| Author | Nick K. |
| Maintainers | octetstream |
| Keywords | wrapper, yaml, parser, serializer |

## Links

- npm: https://www.npmjs.com/package/node-yaml
- Repository: https://github.com/octet-stream/node-yaml
- Homepage: https://github.com/octet-stream/node-yaml#readme
- Issues: https://github.com/octet-stream/node-yaml/issues
- npm.io page: https://npm.io/package/node-yaml

## Dependencies (3)

- [co](https://npm.io/package/co.md) 4.6.0
- [junk](https://npm.io/package/junk.md) 3.1.0
- [promise-fs](https://npm.io/package/promise-fs.md) 2.1.1

## Alternatives

- [monaco-yaml](https://npm.io/package/monaco-yaml.md) — 420.1K weekly downloads
- [@crewx/workflow](https://npm.io/package/@crewx/workflow.md) — 3.1K weekly downloads
- [yaml-cat](https://npm.io/package/yaml-cat.md) — 38 weekly downloads
- [nunjucks-in-yaml](https://npm.io/package/nunjucks-in-yaml.md) — 9 weekly downloads
- [shopify-symlinks](https://npm.io/package/shopify-symlinks.md) — 3 weekly downloads

## Recent versions

- 4.0.1 (latest) — 2019-07-09
- 4.0.0 — 2019-06-23
- 3.2.0 — 2019-03-28
- 3.1.1 — 2017-08-15
- 3.1.0 — 2017-05-16
- 3.0.3 — 2016-10-08
- 3.0.2 — 2016-09-13
- 3.0.1 — 2016-09-13
- 3.0.0 — 2016-07-28
- 2.0.1 — 2016-03-14
- 1.0.2 — 2016-01-25
- 1.0.1 — 2015-12-21
- 1.0.0 — 2015-12-20
- 0.2.2 — 2015-12-02
- 0.2.1 — 2015-12-01
- … 3 more at https://npm.io/package/node-yaml/versions

## README

# Node YAML

A wrapper for [js-yaml](https://github.com/nodeca/js-yaml) parser

[![dependencies Status](https://david-dm.org/octet-stream/node-yaml/status.svg)](https://david-dm.org/octet-stream/node-yaml)
[![devDependencies Status](https://david-dm.org/octet-stream/node-yaml/dev-status.svg)](https://david-dm.org/octet-stream/node-yaml?type=dev)
[![Build Status](https://travis-ci.org/octet-stream/node-yaml.svg?branch=master)](https://travis-ci.org/octet-stream/node-yaml)
[![Code Coverage](https://codecov.io/github/octet-stream/node-yaml/coverage.svg?branch=master)](https://codecov.io/github/octet-stream/node-yaml?branch=master)

This documentation is actual for next major version of the library.
If you want the documentation of current stable version, please check out the [3.x](https://github.com/octet-stream/node-yaml/tree/3.x) branch.

## Installation

You can install this module from Yarn:

```
yarn add node-yaml js-yaml
```

Or using NPM:

```
npm install node-yaml js-yaml
```

## Usage

1. Let's read some file from given path using node-yaml:

```js
import {read} from "node-yaml"

read("path/to/file.yaml")
  .then(res => console.log("File content:\n\n%s", JSON.stringify(res, null, 2)))
  .catch(err => console.error("Error while reading file:\n\n%s", String(err)))
```

2. Both `read` and `readSync` methods allows to omit file extension:

```js
import {readSync} from "node-yaml"

// Will read the content from given path, but also resolve file extension
// Note that if you have 2 files with the same name,
// the first matched will be read.
readSync("path/to/file")
```

## API

##### `yaml.read(filename[, options]) -> {Promise<object>}`

Read and parse YAML file from given path. Takes following arguments:

- **{string | number}** filename – path to file or a file descriptor. Path can omit the file extension.
- **{object}** {options = undefined} – reading options
  + **{string}** [options.encoding = "utf8"] – an encoding used to read the file
  + more options you can find in js-yaml docs in [safeLoad](https://github.com/nodeca/js-yaml#safeload-string---options-) section

##### `yaml.readSync(filename[, options]) -> {object}`

Synchronous version of **yaml.read**

##### `yaml.write(filename, object[, options]) -> {Promise<void>}`

Write given YAML content to disk. Takes following arguments:

- **{string | number}** filename – path to file or a file descriptor. Path can omit the file extension.
- **{object}** object – a content to write to the file
- **{object}** {options = undefined} – writing options
  + **{string}** [options.encoding = "utf8"] – an encoding used to write to the file
  + more options you can find in js-yaml docs in [safeDump](https://github.com/nodeca/js-yaml#safedump-object---options-) section

##### `yaml.writeSync(filename, object[, options]) -> {void}`

Synchronous version of **yaml.write**

---
_Source: https://npm.io/package/node-yaml · Machine-readable twin of the npm.io package page. Health data is recomputed on every publish._
