yml-register

1.2.5 • Public • Published

yml-register

downloads npm GitHub

Hooks into require / import to load .yaml and .yml files.

Usage

From CLI

CJS:

node -r yml-register path/to/index.cjs

ESM (Node.js 20.6.0 or later):

node --import yml-register path/to/index.mjs

Manually import

CJS:

require('yml-register')
require('path/to/file.yml') // now it works!

ESM:

import 'yml-register'
const data = await import('path/to/file.yml') // now it works!

TypeScript support

In order to fixing the error Cannot find module 'file.yml' or its corresponding type declarations. when using import statement in TypeScript, we provides a type declaration bundled in this package.

What you need is to append compilerOptions.types by yml-register/types in tsconfig.json.

{
  "compilerOptions": {
    "types": [
      "yml-register/types",
    ],
  },
}

Package Sidebar

Install

npm i yml-register

Weekly Downloads

1,639

Version

1.2.5

License

MIT

Unpacked Size

8.11 kB

Total Files

6

Last publish

Collaborators

  • shigma