istanbuljs /nyc

the Istanbul command line interface

★ 5,762⑂ 362👁 51⑃ 589● 1,002▤ 3
JavaScriptISCCreated 2015-05-09istanbul.js.org/
Download: nyc: v18.0.0nyc-v18.0.0 ↓18.0.02026-02-22
+0
Daily
5,762
stars
362
forks
51
watchers
589
prs
1,002
issues
3
releases

README

nyc





_Having problems? want to contribute? join our community slack_.

Istanbul's state of the art command line interface, with support for:

 applications that spawn subprocesses.
 source mapped coverage of Babel and TypeScript projects

 How Istanbul works

Istanbul instruments your ES5 and ES2015+ JavaScript code with line counters, so that you can track how well your unit-tests exercise your codebase.

The nyc command-line-client for Istanbul works well with most JavaScript testing frameworks: tap, mocha, AVA, etc.

 Installation & Usage

Use your package manager to add it as a dev dependency: npm i -D nyc or yarn add -D nyc.
You can use nyc to call npm scripts (assuming they don't already have nyc executed in them), like so (replace mocha with your test runner everywhere you see it):

json
{
  "scripts": {
    "test": "mocha",
    "coverage": "nyc npm run test"
  }
}


You can use also npx instead of installing nyc as a dependency, but you might get updates you are not ready for; to get around this, pin to a specific major version by specifying, e.g. nyc@14.

json
{
  "scripts": {
    "test": "npx nyc@latest mocha"
  }
}


This is a good way of testing upcoming releases of nyc, usually on the next tag.

Note: If you use jest or tap, you do not need to install nyc.
Those runners already have the IstanbulJS libraries to provide coverage for you.
Follow their documentation to enable and configure coverage reporting.

 Configuring nyc

nyc accepts a wide variety of configuration arguments, run npx nyc --help for thorough documentation.

Configuration arguments on the command-line should be provided prior to the program that nyc is executing.
As an example, the following command executes ava, and indicates to nyc that it should output both an lcov (lcov.info + html report) and a text-summary coverage report.

shell
nyc --reporter=lcov --reporter=text-summary ava


 Babel projects

Please start with the pre-configured [@istanbuljs/nyc-config-babel] preset.
You can add your custom configuration options as shown below.

 TypeScript projects

Please start with the pre-configured @istanbuljs/nyc-config-typescript preset.

 Adding your overrides

nyc allows you to inherit other configurations using the key extends in the package.json stanza, .nycrc, or YAML files.
You can then add the specific configuration options you want that aren't in that particular shared config, e.g.

json
{
  "extends": "@istanbuljs/nyc-config-typescript",
  "all": true,
  "check-coverage": true
}


 Configuration files

Any configuration options that can be set via the command line can also be specified in the nyc stanza of your package.json, or within a separate configuration file - a variety of flavors are available:

| File name        | File Association                            |
|------------------|---------------------------------------------|
| .nycrc         | JSON                                        |
| .nycrc.json    | JSON                                   

Top issues

Latest release

nyc: v18.0.0 nyc-v18.0.0 2026-02-22
18.0.0 (2026-02-22)


 ⚠ BREAKING CHANGES

 deps: transitive dependencies now require node 20 || =22.

 Bug Fixes

 deps: update dependencies pulling in old glob (1612) (0707729)

Snapshot: 2026-11-16T09:23:14Z · Data license Apache-2.0 · JSON